]> rtime.felk.cvut.cz Git - orte.git/blob - orte/libjorte/createSubInfo.c
Merge branch 'master' of https://github.com/Vajnar/orte
[orte.git] / orte / libjorte / createSubInfo.c
1 /* createSubInfo.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 createSubInfo(JNIEnv *env, const ORTESubInfo *sinfo)
10 {
11   jclass    cls;
12   jobject   obj;
13   jmethodID mid;
14
15   //
16   int flag_ok = 0;
17
18   do {
19     // find cls
20     cls = findClass(env, "org.ocera.orte.types.SubInfo");
21     if (cls == 0) {
22       #ifdef TEST_STAGE
23       printf(":!c: cls = NULL \n");
24       #endif
25       break;
26     }
27     // call object constructor
28     mid = (*env)->GetMethodID(env, cls, "<init>", "()V");
29     if (mid == 0) {
30       #ifdef TEST_STAGE
31       printf(":!c: constructor failed! \n");
32       #endif
33       break;
34     }
35     // create new object
36     obj = (*env)->NewObject(env, cls, mid);
37     if (obj == 0) {
38       #ifdef TEST_STAGE
39       printf(":!c: obj = NULL \n");
40       #endif
41       break;
42     }
43 /////////////////////////////////////////////////
44     // set topic
45     if (!setTopic(env, cls, obj, sinfo->topic)) {
46       #ifdef TEST_STAGE
47       printf(":!c: seTopic() failed! \n");
48       #endif
49       break;
50     }
51     // set type
52     if (!setType(env, cls, obj, sinfo->type)) {
53       #ifdef TEST_STAGE
54       printf(":!c: seType() failed! \n");
55       #endif
56       break;
57     }
58 /////////////////////////////////////////////////
59
60     flag_ok = 1;
61   } while (0);
62
63   if (!flag_ok) {
64     //detach...()
65     return NULL;
66   }
67
68   return obj;
69 }