]> rtime.felk.cvut.cz Git - orte.git/blob - orte/libjorte/createPubInfo.c
Reformat the sources with orte/uncrustify script
[orte.git] / orte / libjorte / createPubInfo.c
1 /* createPubInfo.c  */
2
3 #include <jni.h>
4 #include "orte.h"
5 #include "jorte/4all.h"
6 #include "jorte/jorte_protos_api.h"
7
8 jobject
9 createPubInfo(JNIEnv *env, const ORTEPubInfo *pinfo)
10 {
11   jclass    cls;
12   jobject   obj;
13   jmethodID mid;
14   //
15   int flag_ok = 0;
16
17   do {
18     // find cls
19     cls = findClass(env, "org.ocera.orte.types.PubInfo");
20     if (cls == 0) {
21       #ifdef TEST_STAGE
22       printf(":!c: cls = NULL \n");
23       #endif
24       break;
25     }
26     // call object constructor
27     mid = (*env)->GetMethodID(env, cls, "<init>", "()V");
28     if (mid == 0) {
29       #ifdef TEST_STAGE
30       printf(":!c: constructor failed! \n");
31       #endif
32       break;
33     }
34     // create new object
35     obj = (*env)->NewObject(env, cls, mid);
36     if (obj == 0) {
37       #ifdef TEST_STAGE
38       printf(":!c: obj = NULL \n");
39       #endif
40       break;
41     }
42 /////////////////////////////////////////////////
43     // set topic
44     if (!setTopic(env, cls, obj, pinfo->topic)) {
45       #ifdef TEST_STAGE
46       printf(":!c: seTopic() failed! \n");
47       #endif
48       break;
49     }
50     // set type
51     if (!setType(env, cls, obj, pinfo->type)) {
52       #ifdef TEST_STAGE
53       printf(":!c: seType() failed! \n");
54       #endif
55       break;
56     }
57 /////////////////////////////////////////////////
58
59     flag_ok = 1;
60   } while (0);
61
62   if (!flag_ok) {
63     //detach...()
64     return NULL;
65   }
66
67   return obj;
68 }