javauis/mmapi_qt/baseline/src/videocontrol.cpp
changeset 26 dc7c549001d5
parent 23 98ccebc37403
child 47 f40128debb5d
equal deleted inserted replaced
23:98ccebc37403 26:dc7c549001d5
    33 #include "jstringutils.h"
    33 #include "jstringutils.h"
    34 using namespace java::util;
    34 using namespace java::util;
    35 
    35 
    36 JNIEXPORT jint JNICALL Java_com_nokia_microedition_media_control_VideoControl__1construct
    36 JNIEXPORT jint JNICALL Java_com_nokia_microedition_media_control_VideoControl__1construct
    37 (JNIEnv* aJni, jobject aControlObject, jint aControlHandle,
    37 (JNIEnv* aJni, jobject aControlObject, jint aControlHandle,
    38  jint aEventSourceHandle, jint aToolkitHandle)
    38  jint aEventSourceHandle)
    39 {
    39 {
    40     LOG( EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_VideoControl__1construct + ");
    40     LOG(EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_VideoControl__1construct + ");
    41     CMMAVideoControl* videoControl =
    41     CMMAVideoControl* videoControl =
    42         reinterpret_cast< CMMAVideoControl* >(aControlHandle);
    42         reinterpret_cast< CMMAVideoControl* >(aControlHandle);
    43 
    43 
    44     MMAFunctionServer* eventSource =
    44     MMAFunctionServer* eventSource =
    45         reinterpret_cast< MMAFunctionServer* >(aEventSourceHandle);
    45         reinterpret_cast< MMAFunctionServer* >(aEventSourceHandle);
    53                                KErrArgument));
    53                                KErrArgument));
    54 
    54 
    55     // reference must be done, that events can sent to java side
    55     // reference must be done, that events can sent to java side
    56     jobject controlObject = aJni->NewWeakGlobalRef(aControlObject);
    56     jobject controlObject = aJni->NewWeakGlobalRef(aControlObject);
    57 
    57 
    58    // CMIDToolkit* ptoolkit = JavaUnhand< CMIDToolkit >(aToolkitHandle);
    58     // CMIDToolkit* ptoolkit = JavaUnhand< CMIDToolkit >(aToolkitHandle);
    59    
    59 
    60     //JNIENV_TO_VM(aJni);
    60     //JNIENV_TO_VM(aJni);
    61     TInt error = eventSource->ExecuteTrap(&CMMAVideoControl::ConstructL,
    61     TInt error = eventSource->ExecuteTrap(&CMMAVideoControl::ConstructL,
    62                                           videoControl,
    62                                           videoControl,
    63                                           controlObject,
    63                                           controlObject,
    64                                           eventSource,
    64                                           eventSource,
    65                                           eventSource->getValidJniEnv(), //Passes JavaVM*, not JNIEnv*.
    65                                           eventSource->getValidJniEnv(), //Passes JavaVM*, not JNIEnv*.
    66                                           (MMMAEventPoster*)eventSource/*,
    66                                           (MMMAEventPoster*)eventSource/*,
    67                                           ptoolkit*/);
    67                                           ptoolkit*/);
    68     LOG( EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_VideoControl__1construct - ");
    68     LOG(EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_VideoControl__1construct - ");
    69     return error;
    69     return error;
    70 }
    70 }
    71 
    71 
    72 
    72 
    73 JNIEXPORT jint JNICALL Java_com_nokia_microedition_media_control_VideoControl__1setDisplayProperty
    73 JNIEXPORT jint JNICALL Java_com_nokia_microedition_media_control_VideoControl__1setDisplayProperty
    74 (JNIEnv*, jobject, jint aControlHandle, jint aEventSourceHandle,
    74 (JNIEnv*, jobject, jint aControlHandle, jint aEventSourceHandle,
    75  jint aPropertyA, jint aPropertyB, jint aPropertyType)
    75  jint aPropertyA, jint aPropertyB, jint aPropertyType)
    76 {
    76 {
    77     LOG( EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_VideoControl__1setDisplayProperty");
    77     LOG(EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_VideoControl__1setDisplayProperty");
    78 
    78 
    79     CMMAVideoControl* videoControl =
    79     CMMAVideoControl* videoControl =
    80         reinterpret_cast< CMMAVideoControl* >(aControlHandle);
    80         reinterpret_cast< CMMAVideoControl* >(aControlHandle);
    81 
    81 
    82     MMAFunctionServer* eventSource =
    82     MMAFunctionServer* eventSource =
    92     TInt error(eventSource->ExecuteTrap(&CMMAVideoControl::StaticSetPropertyL,
    92     TInt error(eventSource->ExecuteTrap(&CMMAVideoControl::StaticSetPropertyL,
    93                                         videoControl,
    93                                         videoControl,
    94                                         aPropertyType,
    94                                         aPropertyType,
    95                                         aPropertyA,
    95                                         aPropertyA,
    96                                         aPropertyB));
    96                                         aPropertyB));
    97     LOG( EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_VideoControl__1setDisplayProperty -");
    97     LOG(EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_VideoControl__1setDisplayProperty -");
    98     return error;
    98     return error;
    99 }
    99 }
   100 
   100 
   101 JNIEXPORT jint JNICALL Java_com_nokia_microedition_media_control_VideoControl__1getControlProperty
   101 JNIEXPORT jint JNICALL Java_com_nokia_microedition_media_control_VideoControl__1getControlProperty
   102 (JNIEnv*, jobject, jint aControlHandle, jint aEventSourceHandle,
   102 (JNIEnv*, jobject, jint aControlHandle, jint aEventSourceHandle,
   103  jint aPropertyType)
   103  jint aPropertyType)
   104 {
   104 {
   105     LOG( EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_VideoControl__1getControlProperty");
   105     LOG(EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_VideoControl__1getControlProperty");
   106 
   106 
   107     CMMAVideoControl* videoControl =
   107     CMMAVideoControl* videoControl =
   108         reinterpret_cast< CMMAVideoControl* >(aControlHandle);
   108         reinterpret_cast< CMMAVideoControl* >(aControlHandle);
   109 
   109 
   110     MMAFunctionServer* eventSource =
   110     MMAFunctionServer* eventSource =
   120 
   120 
   121     TInt error(eventSource->ExecuteTrap(&CMMAVideoControl::StaticGetPropertyL,
   121     TInt error(eventSource->ExecuteTrap(&CMMAVideoControl::StaticGetPropertyL,
   122                                         videoControl,
   122                                         videoControl,
   123                                         aPropertyType,
   123                                         aPropertyType,
   124                                         &returnValue));
   124                                         &returnValue));
   125     LOG( EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_VideoControl__1getControlProperty - ");
   125     LOG(EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_VideoControl__1getControlProperty - ");
   126     if (error == KErrNone)
   126     if (error == KErrNone)
   127     {
   127     {
   128         return returnValue;
   128         return returnValue;
   129     }
   129     }
   130     return error;
   130     return error;
   132 
   132 
   133 JNIEXPORT jint JNICALL Java_com_nokia_microedition_media_control_VideoControl__1getSnapshot
   133 JNIEXPORT jint JNICALL Java_com_nokia_microedition_media_control_VideoControl__1getSnapshot
   134 (JNIEnv* aJni, jobject, jint aControlHandle, jint aEventSourceHandle,
   134 (JNIEnv* aJni, jobject, jint aControlHandle, jint aEventSourceHandle,
   135  jstring aProperties)
   135  jstring aProperties)
   136 {
   136 {
   137     LOG( EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_VideoControl__1getSnapshot + ");
   137     LOG(EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_VideoControl__1getSnapshot + ");
   138 
   138 
   139     CMMAVideoControl* videoControl =
   139     CMMAVideoControl* videoControl =
   140         reinterpret_cast< CMMAVideoControl* >(aControlHandle);
   140         reinterpret_cast< CMMAVideoControl* >(aControlHandle);
   141 
   141 
   142     MMAFunctionServer* eventSource =
   142     MMAFunctionServer* eventSource =
   151 
   151 
   152     JStringUtils properties(*aJni, aProperties);
   152     JStringUtils properties(*aJni, aProperties);
   153     TInt error(eventSource->ExecuteTrap(&CMMAVideoControl::TakeSnapShotL,
   153     TInt error(eventSource->ExecuteTrap(&CMMAVideoControl::TakeSnapShotL,
   154                                         videoControl,
   154                                         videoControl,
   155                                         (const TDesC*)&properties));
   155                                         (const TDesC*)&properties));
   156     LOG( EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_VideoControl__1getSnapshot - ");
   156     LOG(EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_VideoControl__1getSnapshot - ");
   157     return error;
   157     return error;
   158 }
   158 }
   159 
   159 
   160 /**
   160 /**
   161  * Initializes dynamic display mode
   161  * Initializes dynamic display mode
   162  * @return handle to MMMADirectContent or error code
   162  * @return handle to MMMADirectContent or error code
   163  */
   163  */
       
   164 /*
   164 LOCAL_C jint InitDynamicMode(MMAFunctionServer* aEventSource,
   165 LOCAL_C jint InitDynamicMode(MMAFunctionServer* aEventSource,
   165                              CMMAVideoControl* aVideoControl,
   166                              CMMAVideoControl* aVideoControl,
   166                              jobject aGUIObject,
   167                              jobject aGUIObject,
   167                              CMMAEvent* aDeleteRefEvent)
   168                              CMMAEvent* aDeleteRefEvent)
   168 {
   169 {
   180     {
   181     {
   181         contentHandle = error;
   182         contentHandle = error;
   182     }
   183     }
   183     return contentHandle;
   184     return contentHandle;
   184 }
   185 }
       
   186 */
   185 
   187 
   186 JNIEXPORT jint JNICALL Java_com_nokia_microedition_media_control_VideoControl__1initDisplayMode
   188 JNIEXPORT jint JNICALL Java_com_nokia_microedition_media_control_VideoControl__1initDisplayMode
   187 (JNIEnv* aJni, jobject aJavaVideoControl, jint aControlHandle, jint aEventSourceHandle,
   189 (JNIEnv* aJni, jobject aJavaVideoControl, jint aControlHandle, jint aEventSourceHandle,
   188  jobject aJavaDisplayObj, jobject aComponent)
   190  jobject aJavaDisplayObj, jobject aComponent,jboolean aGuiType)
   189 {
   191 {
   190     LOG( EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_VideoControl__1initDisplayMode +");
   192     LOG(EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_VideoControl__1initDisplayMode +");
   191     LOG1( EJavaMMAPI, EInfo, "aControlHandle = %d", aControlHandle);
   193     LOG1(EJavaMMAPI, EInfo, "aControlHandle = %d", aControlHandle);
   192     LOG1( EJavaMMAPI, EInfo, "aEventSourceHandle = %d", aEventSourceHandle);
   194     LOG1(EJavaMMAPI, EInfo, "aEventSourceHandle = %d", aEventSourceHandle);
   193 //    LOG1( EJavaMMAPI, EInfo, "aComponentHandle = %d", aComponentHandle);
   195 //    LOG1( EJavaMMAPI, EInfo, "aComponentHandle = %d", aComponentHandle);
   194 
   196 
   195     CMMAVideoControl* videoControl =
   197     TBool type = aGuiType;
   196         reinterpret_cast< CMMAVideoControl* >(aControlHandle);
   198     CMMAVideoControl* videoControl =
   197 
   199         reinterpret_cast< CMMAVideoControl* >(aControlHandle);
   198     MMAFunctionServer* eventSource =
   200 
   199         reinterpret_cast< MMAFunctionServer *>(aEventSourceHandle);
   201     MMAFunctionServer* eventSource =
   200         
   202         reinterpret_cast< MMAFunctionServer *>(aEventSourceHandle);
       
   203 
   201     jobject javaVideoControlPeer = aJni->NewWeakGlobalRef(aJavaVideoControl);
   204     jobject javaVideoControlPeer = aJni->NewWeakGlobalRef(aJavaVideoControl);
   202 
   205 
   203     // Reference need to created to the component that component won't be deleted
   206     // Reference need to created to the component that component won't be deleted
   204     // before display associated to it.
   207     // before display associated to it.
   205     jobject componentRef = aJni->NewGlobalRef(aComponent);
   208     jobject componentRef = aJni->NewGlobalRef(aComponent);
   218         return KErrNoMemory;
   221         return KErrNoMemory;
   219     }
   222     }
   220 
   223 
   221 // for javaside display object  // TODO:  delete this object after its not required in destructor of control
   224 // for javaside display object  // TODO:  delete this object after its not required in destructor of control
   222 
   225 
   223 	// Reference need to created to the component that component won't be deleted
   226     // Reference need to created to the component that component won't be deleted
   224     // before display associated to it.
   227     // before display associated to it.
   225     jobject javaDisplayRef = aJni->NewGlobalRef(aJavaDisplayObj);
   228     jobject javaDisplayRef = aJni->NewGlobalRef(aJavaDisplayObj);
   226     if (javaDisplayRef == NULL)
   229     if (javaDisplayRef == NULL)
   227     {
   230     {
   228         return KErrNoMemory;
   231         return KErrNoMemory;
   234         return InitDynamicMode(eventSource,
   237         return InitDynamicMode(eventSource,
   235                                videoControl,
   238                                videoControl,
   236                                componentRef,
   239                                componentRef,
   237                                deleteRefEvent);
   240                                deleteRefEvent);
   238     }
   241     }
   239 	*/
   242     */
   240   //  MMIDComponent* component = JavaUnhand< MMIDComponent >(aComponentHandle);
   243     //  MMIDComponent* component = JavaUnhand< MMIDComponent >(aComponentHandle);
   241 
   244 
   242 
   245 
   243     __ASSERT_DEBUG(videoControl,
   246     __ASSERT_DEBUG(videoControl,
   244                    User::Panic(_L("videocontrol::control is null"),
   247                    User::Panic(_L("videocontrol::control is null"),
   245                                KErrArgument));
   248                                KErrArgument));
   254     TInt error(eventSource->ExecuteTrap(&CMMAVideoControl::StaticInitL,
   257     TInt error(eventSource->ExecuteTrap(&CMMAVideoControl::StaticInitL,
   255                                         videoControl,
   258                                         videoControl,
   256                                         javaDisplayRef,
   259                                         javaDisplayRef,
   257                                         eventSource,
   260                                         eventSource,
   258                                         &handle,
   261                                         &handle,
   259                                         deleteRefEvent));
   262                                         deleteRefEvent,
   260     LOG( EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_VideoControl__1initDisplayMode - ");
   263                                         type));
       
   264     LOG(EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_VideoControl__1initDisplayMode - ");
   261     if (error == KErrNone)
   265     if (error == KErrNone)
   262     {
   266     {
   263         return handle;
   267         return handle;
   264     }
   268     }
   265     return error;
   269     return error;
   266 }
   270 }
   267 
   271 
   268 JNIEXPORT jint JNICALL Java_com_nokia_microedition_media_control_VideoControl__1setForeground
   272 JNIEXPORT jint JNICALL Java_com_nokia_microedition_media_control_VideoControl__1setForeground
   269 (JNIEnv* /*aJni*/, jobject, jint aControlHandle, jint aEventSourceHandle, jint aIsForeground)
   273 (JNIEnv* /*aJni*/, jobject, jint aControlHandle, jint aEventSourceHandle, jint aIsForeground)
   270 {
   274 {
   271     LOG1( EJavaMMAPI, EInfo, "_1setForeground + FOREGROUND = %d",aIsForeground);
   275     LOG1(EJavaMMAPI, EInfo, "_1setForeground + FOREGROUND = %d",aIsForeground);
   272     CMMAVideoControl* videoControl =
   276     CMMAVideoControl* videoControl =
   273         reinterpret_cast< CMMAVideoControl *>(aControlHandle);
   277         reinterpret_cast< CMMAVideoControl *>(aControlHandle);
   274 
   278 
   275     MMAFunctionServer* eventSource =
   279     MMAFunctionServer* eventSource =
   276         reinterpret_cast< MMAFunctionServer *>(aEventSourceHandle);
   280         reinterpret_cast< MMAFunctionServer *>(aEventSourceHandle);
   279     TInt error(eventSource->ExecuteTrap(&CMMAVideoControl::StaticSetForegroundL,
   283     TInt error(eventSource->ExecuteTrap(&CMMAVideoControl::StaticSetForegroundL,
   280                                         videoControl,
   284                                         videoControl,
   281                                         aIsForeground));
   285                                         aIsForeground));
   282     if (error == KErrNone)
   286     if (error == KErrNone)
   283     {
   287     {
   284         LOG( EJavaMMAPI, EInfo, "_1setForeground -");
   288         LOG(EJavaMMAPI, EInfo, "_1setForeground -");
   285         return handle;
   289         return handle;
   286     }
   290     }
   287 
   291 
   288     LOG( EJavaMMAPI, EInfo, "_1setForeground -");
   292     LOG(EJavaMMAPI, EInfo, "_1setForeground -");
   289     return error;
   293     return error;
   290 }
   294 }
   291 JNIEXPORT jboolean JNICALL Java_com_nokia_microedition_media_control_VideoControl__1isESWT
   295 JNIEXPORT jboolean JNICALL Java_com_nokia_microedition_media_control_VideoControl__1isESWT
   292 (JNIEnv *, jobject)
   296 (JNIEnv *, jobject)
   293 {/*
   297 {
   294     MSwtClient* client = NULL;
   298     /*
   295     TRAP_IGNORE(client = SWT::CreateClientL());
   299        MSwtClient* client = NULL;
   296 
   300        TRAP_IGNORE(client = SWT::CreateClientL());
   297     if (!client)
   301 
   298     {
   302        if (!client)
   299         return false; // LCDUI midlet running
   303        {
   300     }
   304            return false; // LCDUI midlet running
   301     else
   305        }
   302     {
   306        else
   303         delete client;
   307        {
   304         client = NULL;
   308            delete client;
   305         return true;  // eSWT midlet running
   309            client = NULL;
   306     }
   310            return true;  // eSWT midlet running
   307 */
   311        }
       
   312     */
   308     // enable above code once you have support for eswt in 3.2.3, it is already enable for 5.0
   313     // enable above code once you have support for eswt in 3.2.3, it is already enable for 5.0
   309 return false;
   314     return false;
   310 }
   315 }
   311 //  END OF FILE
   316 //  END OF FILE