mmsharing/livecommsui/lcuiengine/tsrc/win32/lcuiengine_p.cpp
branchRCL_3
changeset 23 bc78a40cd63c
parent 22 73a1feb507fb
child 24 6c57ef9392d2
equal deleted inserted replaced
22:73a1feb507fb 23:bc78a40cd63c
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 //USER
       
    19 #include "lcuiengine_p.h"
       
    20 #include "lcuidefs.h"
       
    21 #include "lclogger.h"
       
    22 #include "lcuienginesimulator.h"
       
    23 
       
    24 //SYSTEM
       
    25 #include <QTimer>
       
    26 #include <hbdialog.h>
       
    27 #include <hblineedit.h>
       
    28 #include <hbinstance.h>
       
    29 
       
    30 
       
    31 #define LC_VTPLUGIN_NAME "Videotelephony";
       
    32 
       
    33 const char localMovieName[] = "c:\\data\\local.3gp";
       
    34 const char local2MovieName[] = "c:\\data\\local2.mpeg";
       
    35 const char remoteMovieName[] = "c:\\data\\remote.3gp";
       
    36 const char mPlayer[] = "c:\\data\\mplayer.exe";
       
    37 const char msPaint[] = "mspaint";
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // LcUiEnginePrivate::LcUiEnginePrivate
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 LcUiEnginePrivate::LcUiEnginePrivate( LcUiEngine& uiEngine,
       
    44                                       const QString& engineName,
       
    45                                       const QString& applicationDisplayName)
       
    46     :mUiEngine( uiEngine )
       
    47 {
       
    48     LC_QDEBUG( "livecomms [UI] -> LcUiEnginePrivate::LcUiEnginePrivate()" )                 
       
    49     mSimulator = new LcUiEngineSimulator( *this );
       
    50     mViewLayout = (LcViewLayoutHint)mSimulator->layout();
       
    51     mSessionTitle = mSimulator->sessionTitle();
       
    52     mRecipient =  mSimulator->remoteAddress();
       
    53     mPhoneNumber = mSimulator->phoneNo();        
       
    54     mLocalPlayerProcess = new QProcess();
       
    55     mRemotePlayerProcess = new QProcess();
       
    56     mProgram = QString::fromAscii(mPlayer);
       
    57     mProgramImage = QString::fromAscii(msPaint);
       
    58     mLocalMovieName = QString::fromAscii(localMovieName);
       
    59     LC_QDEBUG( "livecomms [UI] <- LcUiEnginePrivate::LcUiEnginePrivate()" )
       
    60 }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // LcUiEnginePrivate::~LcUiEnginePrivate
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 LcUiEnginePrivate::~LcUiEnginePrivate()
       
    67 {
       
    68     LC_QDEBUG( "livecomms [UI] -> LcUiEnginePrivate::~LcUiEnginePrivate()" )
       
    69     delete mSimulator;
       
    70     delete mLocalPlayerProcess;
       
    71     delete mRemotePlayerProcess;    
       
    72     LC_QDEBUG( "livecomms [UI] <- LcUiEnginePrivate::~LcUiEnginePrivate()" )
       
    73 }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // LcUiEnginePrivate::zoom
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 void LcUiEnginePrivate::zoom( int value )
       
    80 {
       
    81     LC_QDEBUG( "livecomms [UI] -> LcUiEnginePrivate::zoom()" )
       
    82 
       
    83     LC_QDEBUG( "livecomms [UI] <- LcUiEnginePrivate::zoom()" )
       
    84 }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // LcUiEnginePrivate::stop
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 void LcUiEnginePrivate::stop()
       
    91 {
       
    92     LC_QDEBUG( "livecomms [UI] -> LcUiEnginePrivate::stop()" )    
       
    93     mSimulator->stop();    
       
    94     LC_QDEBUG( "livecomms [UI] <- LcUiEnginePrivate::stop()" )
       
    95 }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // LcUiEnginePrivate::start
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 void LcUiEnginePrivate::start()
       
   102 {
       
   103     LC_QDEBUG( "livecomms [UI] -> LcUiEnginePrivate::start()" )
       
   104     mSimulator->start();
       
   105     LC_QDEBUG( "livecomms [UI] <- LcUiEnginePrivate::start()" )
       
   106 }
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // LcUiEnginePrivate::sessionTitle
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 const QString& LcUiEnginePrivate::sessionTitle() const
       
   113 {
       
   114     return mSessionTitle;
       
   115 }
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // LcUiEnginePrivate::recipient
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 const QString& LcUiEnginePrivate::recipient() const
       
   122 {
       
   123     return mRecipient;
       
   124 }
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 // LcUiEnginePrivate::phoneNumber
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 const QString& LcUiEnginePrivate::phoneNumber() const
       
   131 {
       
   132     return mPhoneNumber;
       
   133 }
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // LcUiEnginePrivate::viewLayout
       
   137 // -----------------------------------------------------------------------------
       
   138 //
       
   139 LcViewLayoutHint LcUiEnginePrivate::viewLayout() const
       
   140 {
       
   141     return mViewLayout;
       
   142 }
       
   143 
       
   144 // -----------------------------------------------------------------------------
       
   145 // LcUiEnginePrivate::setContentAreas
       
   146 // -----------------------------------------------------------------------------
       
   147 //
       
   148 void LcUiEnginePrivate::setContentAreas( const QRectF& sharedContent,
       
   149                                   const QRectF& receivedContent )
       
   150 {
       
   151     LC_QDEBUG( "livecomms [UI] -> LcUiEnginePrivate::setContentAreas()" )
       
   152     LC_QDEBUG_2( "livecomms [UI] shared window: ",  sharedContent )
       
   153     LC_QDEBUG_2( "livecomms [UI] received window: ",  receivedContent )    
       
   154     LC_QDEBUG( "livecomms [UI] <- LcUiEnginePrivate::setContentAreas()" )
       
   155 }
       
   156 
       
   157 // -----------------------------------------------------------------------------
       
   158 // LcUiEnginePrivate::setOrientation
       
   159 // -----------------------------------------------------------------------------
       
   160 //
       
   161 bool LcUiEnginePrivate::setOrientation( Qt::Orientation orientation )
       
   162 {
       
   163     bool ok( false );
       
   164     return ok;
       
   165 }
       
   166 
       
   167 // -----------------------------------------------------------------------------
       
   168 // LcUiEnginePrivate::setUiComponents
       
   169 // -----------------------------------------------------------------------------
       
   170 //
       
   171 void LcUiEnginePrivate::setUiComponents(
       
   172         HbDialog* invitingNote,
       
   173         HbDialog* waitingNote,
       
   174         HbDialog* acceptQuery,
       
   175         HbDialog* recipientQuery )
       
   176 {
       
   177     mInvitingNote = invitingNote;
       
   178     mWaitingNote = waitingNote;
       
   179     mAcceptQuery = acceptQuery;
       
   180     mRecipientQuery = recipientQuery;
       
   181     
       
   182 
       
   183 }
       
   184 
       
   185 // -----------------------------------------------------------------------------
       
   186 // LcUiEnginePrivate::toggleMute
       
   187 // -----------------------------------------------------------------------------
       
   188 //
       
   189 void LcUiEnginePrivate::toggleMute()
       
   190 {
       
   191     LC_QDEBUG( "livecomms [UI] -> LcUiEnginePrivate::toggleMute()" )        
       
   192     if( mMuteState ){
       
   193         unmuted();
       
   194     }else{
       
   195         muted();
       
   196     }
       
   197     LC_QDEBUG( "livecomms [UI] <- LcUiEnginePrivate::toggleMute()" )
       
   198 }
       
   199 
       
   200 // -----------------------------------------------------------------------------
       
   201 // LcUiEnginePrivate::isMuted
       
   202 // -----------------------------------------------------------------------------
       
   203 //
       
   204 bool LcUiEnginePrivate::isMuted() const
       
   205 {
       
   206     return mMuteState;
       
   207 }
       
   208 
       
   209 // -----------------------------------------------------------------------------
       
   210 // LcUiEnginePrivate::toggleSpeaker
       
   211 // -----------------------------------------------------------------------------
       
   212 //
       
   213 void LcUiEnginePrivate::toggleSpeaker()
       
   214 {
       
   215     LC_QDEBUG( "livecomms [UI] -> LcUiEnginePrivate::toggleSpeaker()" )
       
   216     if ( mSpeakerState ){
       
   217         speakerDisabled();
       
   218     }else{
       
   219         speakerEnabled();
       
   220     }
       
   221     LC_QDEBUG( "livecomms [UI] <- LcUiEnginePrivate::toggleSpeaker()" )
       
   222 }
       
   223 
       
   224 // -----------------------------------------------------------------------------
       
   225 // LcUiEnginePrivate::isSpeakerOn
       
   226 // -----------------------------------------------------------------------------
       
   227 //
       
   228 bool LcUiEnginePrivate::isSpeakerOn() const
       
   229 {    
       
   230     return mSpeakerState;
       
   231 }
       
   232 
       
   233 // -----------------------------------------------------------------------------
       
   234 // LcUiEnginePrivate::zoomValues
       
   235 // -----------------------------------------------------------------------------
       
   236 //
       
   237 int LcUiEnginePrivate::zoomValues( LcControlValues& values ) const
       
   238 {
       
   239     int err( 1 );
       
   240     return err;
       
   241 }
       
   242 
       
   243 // -----------------------------------------------------------------------------
       
   244 // LcUiEnginePrivate::toggleEnableCamera
       
   245 // -----------------------------------------------------------------------------
       
   246 //
       
   247 void LcUiEnginePrivate::toggleDisableCamera()
       
   248 {
       
   249     LC_QDEBUG( "livecomms [UI] -> LcUiEnginePrivate::toggleDisableCamera()" )            
       
   250     if( mPlayerStateLocal == EPlaying ){
       
   251         localPlayerPaused();
       
   252         cameraDisabled();
       
   253     }else if( mPlayerStateLocal == EPaused){
       
   254         localPlayerPlaying();
       
   255         cameraEnabled();
       
   256     }
       
   257     LC_QDEBUG( "livecomms [UI] <- LcUiEnginePrivate::toggleDisableCamera()" )
       
   258 }
       
   259 
       
   260 // -----------------------------------------------------------------------------
       
   261 // LcUiEnginePrivate::setCameraMain
       
   262 // -----------------------------------------------------------------------------
       
   263 //
       
   264 void LcUiEnginePrivate::setMainCamera(const bool aMainCamera)
       
   265 {
       
   266     LC_QDEBUG_2( "livecomms [UI] -> LcUiEnginePrivate::setCameraMain()", aMainCamera )
       
   267     if(aMainCamera){
       
   268         cameraChangedToMain();
       
   269     }else{
       
   270         cameraChangedToSecondary();
       
   271     }
       
   272     LC_QDEBUG( "livecomms [UI] <- LcUiEnginePrivate::setCameraMain()" )
       
   273 }
       
   274 
       
   275 // -----------------------------------------------------------------------------
       
   276 // LcUiEnginePrivate::cameraIndex
       
   277 // -----------------------------------------------------------------------------
       
   278 //
       
   279 bool LcUiEnginePrivate::mainCamera() const
       
   280 {
       
   281     LC_QDEBUG( "livecomms [UI] -> LcUiEnginePrivate::mainCamera()" )
       
   282     LC_QDEBUG_2( "livecomms [UI] <- LcUiEnginePrivate::mainCamera()", mMainCamera )
       
   283     return mMainCamera;
       
   284 }
       
   285 
       
   286 // -----------------------------------------------------------------------------
       
   287 // LcUiEnginePrivate::toggleCamera
       
   288 // -----------------------------------------------------------------------------
       
   289 //
       
   290 void LcUiEnginePrivate::toggleCamera()
       
   291 {
       
   292     LC_QDEBUG( "livecomms [UI] -> LcUiEnginePrivate::toggleCamera()" )
       
   293     if( mMainCamera ){
       
   294         cameraChangedToSecondary();
       
   295     }else{
       
   296         cameraChangedToMain();
       
   297     }
       
   298     if( mPlayerStateLocal==EPlaying ){
       
   299         localPlayerPaused();
       
   300         mSimulator->setSimulation(2);
       
   301         mSimulator->start();
       
   302     }
       
   303     LC_QDEBUG_2( "livecomms [UI] <- LcUiEnginePrivate::toggleCamera(), mainCamera:", mMainCamera )
       
   304 }
       
   305 
       
   306 // -----------------------------------------------------------------------------
       
   307 // LcUiEnginePrivate::fullScreenMode
       
   308 // -----------------------------------------------------------------------------
       
   309 //
       
   310 bool LcUiEnginePrivate::fullScreenMode()
       
   311 {
       
   312     LC_QDEBUG( "livecomms [UI] -> LcUiEnginePrivate::fullScreenMode()" )
       
   313     LC_QDEBUG( "livecomms [UI] <- LcUiEnginePrivate::fullScreenMode()" )
       
   314     return mFullScreen;
       
   315 }
       
   316 
       
   317 // -----------------------------------------------------------------------------
       
   318 // LcUiEnginePrivate::setFullScreenMode
       
   319 // -----------------------------------------------------------------------------
       
   320 //
       
   321 void LcUiEnginePrivate::setFullScreenMode(bool aMode)
       
   322 {
       
   323     LC_QDEBUG( "livecomms [UI] -> LcUiEnginePrivate::setFullScreenMode()" )
       
   324     mFullScreen = aMode;
       
   325     LC_QDEBUG( "livecomms [UI] <- LcUiEnginePrivate::setFullScreenMode()" )
       
   326 }
       
   327 
       
   328 
       
   329 // -----------------------------------------------------------------------------
       
   330 // LcUiEnginePrivate::updateSession
       
   331 // -----------------------------------------------------------------------------
       
   332 //
       
   333 void LcUiEnginePrivate::updateSession()
       
   334 {
       
   335     LC_QDEBUG( "livecomms [UI] -> LcUiEnginePrivate::updateSession()" )
       
   336     
       
   337     LC_QDEBUG( "livecomms [UI] <- LcUiEnginePrivate::updateSession()" )
       
   338 }
       
   339 
       
   340 // -----------------------------------------------------------------------------
       
   341 // LcUiEnginePrivate::isLocalPlayerPlaying
       
   342 // -----------------------------------------------------------------------------
       
   343 //
       
   344 bool LcUiEnginePrivate::isLocalPlayerPlaying() const
       
   345 {
       
   346     return ( mPlayerStateLocal == EPlaying )? true : false;
       
   347 }
       
   348 
       
   349 // -----------------------------------------------------------------------------
       
   350 // LcUiEnginePrivate::isRemotePlayerPlaying
       
   351 // -----------------------------------------------------------------------------
       
   352 //
       
   353 bool LcUiEnginePrivate::isRemotePlayerPlaying() const
       
   354 {
       
   355     return ( mSimulatorRemote == EPlaying )? true : false;
       
   356 }
       
   357 
       
   358 // -----------------------------------------------------------------------------
       
   359 // LcUiEnginePrivate::localPlayerPlaying
       
   360 // -----------------------------------------------------------------------------
       
   361 //
       
   362 void LcUiEnginePrivate::localPlayerPlaying()
       
   363 {    
       
   364     QStringList args;
       
   365     args << mLocalMovieName;
       
   366     mLocalPlayerProcess->start(mProgram,args);        
       
   367     mPlayerStateLocal=EPlaying;
       
   368     emit mUiEngine.localPlayerPlaying();
       
   369 }
       
   370 
       
   371 
       
   372 // -----------------------------------------------------------------------------
       
   373 // LcUiEnginePrivate::remotePlayerPlaying
       
   374 // -----------------------------------------------------------------------------
       
   375 //
       
   376 void LcUiEnginePrivate::remotePlayerPlaying()
       
   377 {
       
   378     QStringList args;
       
   379     args << QString::fromAscii(remoteMovieName);    
       
   380     mRemotePlayerProcess->start(mProgram,args);    
       
   381     mSimulatorRemote=EPlaying;
       
   382     emit mUiEngine.remotePlayerPlaying();
       
   383 }
       
   384 
       
   385 // -----------------------------------------------------------------------------
       
   386 // LcUiEnginePrivate::localPlayerPaused
       
   387 // -----------------------------------------------------------------------------
       
   388 //
       
   389 void LcUiEnginePrivate::localPlayerPaused()
       
   390 {    
       
   391     mLocalPlayerProcess->close();       
       
   392     mPlayerStateLocal=EPaused;
       
   393     emit mUiEngine.localPlayerPaused();
       
   394 }
       
   395 
       
   396 // -----------------------------------------------------------------------------
       
   397 // LcUiEnginePrivate::remotePlayerPaused
       
   398 // -----------------------------------------------------------------------------
       
   399 //
       
   400 void LcUiEnginePrivate::remotePlayerPaused()
       
   401 {    
       
   402     mRemotePlayerProcess->close();    
       
   403     mSimulatorRemote=EPaused;
       
   404     emit mUiEngine.remotePlayerPaused();
       
   405 }
       
   406 
       
   407 // -----------------------------------------------------------------------------
       
   408 // LcUiEnginePrivate::cameraChangedToSecondary
       
   409 // -----------------------------------------------------------------------------
       
   410 //
       
   411 void LcUiEnginePrivate::cameraChangedToSecondary()
       
   412 {
       
   413     mLocalMovieName= QString::fromAscii(local2MovieName);
       
   414     mMainCamera=false;
       
   415     emit mUiEngine.cameraChangedToSecondary();
       
   416 }
       
   417 
       
   418 
       
   419 // -----------------------------------------------------------------------------
       
   420 // LcUiEnginePrivate::cameraChangedToSecondary
       
   421 // -----------------------------------------------------------------------------
       
   422 //
       
   423 void LcUiEnginePrivate::cameraChangedToMain()
       
   424 {
       
   425     mLocalMovieName= QString::fromAscii(localMovieName);
       
   426     mMainCamera=true;
       
   427     emit mUiEngine.cameraChangedToMain();
       
   428 }
       
   429 
       
   430 // -----------------------------------------------------------------------------
       
   431 // LcUiEnginePrivate::isMinimized
       
   432 // -----------------------------------------------------------------------------
       
   433 //
       
   434 bool LcUiEnginePrivate::isMinimized() const
       
   435 {
       
   436     return (QApplication::activeWindow()->windowState()==Qt::WindowMinimized);
       
   437 }
       
   438 
       
   439 // -----------------------------------------------------------------------------
       
   440 // LcUiEnginePrivate::minimize
       
   441 // -----------------------------------------------------------------------------
       
   442 //
       
   443 void LcUiEnginePrivate::minimize()
       
   444 {
       
   445     QApplication::activeWindow()->setWindowState(Qt::WindowMinimized);
       
   446 }
       
   447 
       
   448 // -----------------------------------------------------------------------------
       
   449 // LcUiEnginePrivate::maximize
       
   450 // -----------------------------------------------------------------------------
       
   451 //
       
   452 void LcUiEnginePrivate::maximize()
       
   453 {
       
   454     QApplication::activeWindow()->setWindowState(Qt::WindowMaximized);
       
   455 }
       
   456 
       
   457 // -----------------------------------------------------------------------------
       
   458 // LcUiEnginePrivate::shareImage
       
   459 // -----------------------------------------------------------------------------
       
   460 //
       
   461 void LcUiEnginePrivate::shareImage(const QString& fileName)
       
   462 {
       
   463     localPlayerPaused();    
       
   464     QStringList args;
       
   465     args << fileName;
       
   466     mLocalPlayerProcess->start(mProgramImage,args);
       
   467     mPlayerStateLocal=EPlaying;
       
   468     emit mUiEngine.localPlayerPlaying();
       
   469 }
       
   470 
       
   471 // -----------------------------------------------------------------------------
       
   472 // LcUiEnginePrivate::shareCamera
       
   473 // -----------------------------------------------------------------------------
       
   474 //
       
   475 void LcUiEnginePrivate::shareCamera()
       
   476 {
       
   477     localPlayerPaused();
       
   478     localPlayerPlaying();
       
   479 }
       
   480 // End of File