]> rtime.felk.cvut.cz Git - orte.git/blob - orte/libjorte/createPubInfo.c
16c2ac13b56072e9370136812584a3144aa17d08
[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 createPubInfo(JNIEnv *env, const ORTEPubInfo *pinfo)
9 {
10   jclass    cls;
11   jobject   obj;
12   jmethodID mid;
13   //
14   int flag_ok = 0;
15
16   do
17   {
18     // find cls
19     cls = findClass(env, "org.ocera.orte.types.PubInfo");
20     if(cls == 0)
21     {
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     {
31       #ifdef TEST_STAGE
32         printf(":!c: constructor failed! \n");
33       #endif
34       break;
35     }
36     // create new object
37     obj = (*env)->NewObject(env, cls, mid);
38     if(obj == 0)
39     {
40       #ifdef TEST_STAGE
41         printf(":!c: obj = NULL \n");
42       #endif
43       break;
44     }
45 /////////////////////////////////////////////////
46     // set topic
47     if(!setTopic(env,cls,obj,pinfo->topic))
48     {
49       #ifdef TEST_STAGE
50         printf(":!c: seTopic() failed! \n");
51       #endif
52       break;
53     }
54     // set type
55     if(!setType(env,cls,obj,pinfo->type))
56     {
57       #ifdef TEST_STAGE
58         printf(":!c: seType() failed! \n");
59       #endif
60       break;
61     }
62 /////////////////////////////////////////////////
63
64     flag_ok = 1;
65   } while(0);
66
67   if(!flag_ok)
68   {
69     //detach...()
70     return NULL;
71   }
72
73 return obj;
74 }