textinput/peninputarc/src/peninputclient/penclientimpl.cpp
branchRCL_3
changeset 20 ebd48d2de13c
parent 15 6c2c2d3ab788
child 21 ecbabf52600f
equal deleted inserted replaced
19:ac7e4d1d9209 20:ebd48d2de13c
    27 #include <apgcli.h>
    27 #include <apgcli.h>
    28 #include <s32mem.h>
    28 #include <s32mem.h>
    29 #include <coemain.h>
    29 #include <coemain.h>
    30 #include <apgwgnam.h>
    30 #include <apgwgnam.h>
    31 #include "peninputclient.h"
    31 #include "peninputclient.h"
    32 #ifndef FIX_FOR_NGA
       
    33 #define FIX_FOR_NGA
       
    34 #endif
       
    35 const TUint KDefaultMessageSlots = 4;
    32 const TUint KDefaultMessageSlots = 4;
    36 
    33 
    37 const TInt KMaxSupportLanguages = 100;
    34 const TInt KMaxSupportLanguages = 100;
    38 const TInt KMaxImeImplementations = 10;
    35 const TInt KMaxImeImplementations = 10;
    39 const TUid KSingletonClientId = 
    36 const TUid KSingletonClientId = 
    75     {
    72     {
    76     return  AppUidFromWndGroupId(CCoeEnv::Static()->RootWin().Identifier());
    73     return  AppUidFromWndGroupId(CCoeEnv::Static()->RootWin().Identifier());
    77     }
    74     }
    78     
    75     
    79     
    76     
       
    77    
       
    78 CPeninputServerWaiter* CPeninputServerWaiter::NewL()
       
    79     {
       
    80     CPeninputServerWaiter* self = new(ELeave)CPeninputServerWaiter;
       
    81     CleanupStack::PushL(self);
       
    82     self->ConstructL();
       
    83     CleanupStack::Pop(self);
       
    84     return self;
       
    85     }
       
    86 void CPeninputServerWaiter::ConstructL()    
       
    87     {
       
    88     iWaitScheduler = new(ELeave) CActiveSchedulerWait;
       
    89     }
       
    90     
       
    91 CPeninputServerWaiter::~CPeninputServerWaiter()
       
    92     {
       
    93     delete iWaitScheduler;
       
    94     }
       
    95     
       
    96 void CPeninputServerWaiter::Start()
       
    97     {
       
    98     iWaitScheduler->Start();
       
    99     }
       
   100     
       
   101 void CPeninputServerWaiter::Stop(TInt aFlag)
       
   102     {
       
   103     //if(aFlag)
       
   104     iError = aFlag ? KErrNone : aFlag;
       
   105     
       
   106     iWaitScheduler->AsyncStop();
       
   107     }
       
   108     
       
   109     
       
   110     
    80 // ======== MEMBER FUNCTIONS ========
   111 // ======== MEMBER FUNCTIONS ========
    81 
   112 
    82 // ---------------------------------------------------------------------------
   113 // ---------------------------------------------------------------------------
    83 // RPeninputServerImpl::NewL
   114 // RPeninputServerImpl::NewL
    84 // ---------------------------------------------------------------------------
   115 // ---------------------------------------------------------------------------
    85 //
   116 //
    86 RPeninputServerImpl* RPeninputServerImpl::NewL(TRequestStatus* aStatus)                                  
   117 RPeninputServerImpl* RPeninputServerImpl::NewL()                                  
    87     {
   118     {
    88     //check for singleton existence    
   119     //check for singleton existence    
    89     CCoeStatic * obj = CCoeEnv::Static()->FindStatic(KSingletonClientId);
   120     CCoeStatic * obj = CCoeEnv::Static()->FindStatic(KSingletonClientId);
    90     CPenInputSingletonClient* client = 
   121     CPenInputSingletonClient* client = 
    91                                 static_cast<CPenInputSingletonClient*>(obj);
   122                                 static_cast<CPenInputSingletonClient*>(obj);
    92     if(client && client->IsValid())
   123     if(client && client->IsValid())
    93         {
   124         {
    94         RPeninputServerImpl* server = client->GetSingletonServer();
   125         RPeninputServerImpl* server = client->GetSingletonServer();
    95         TInt err = server->ServerReady() ? KErrNone : KErrLaunchingServer;
   126         return server;
    96         if ( aStatus )
   127 /*        if(iSingletonServer == 0 ) // second or later connecting from same client
    97             {
   128             {
    98             User::RequestComplete( aStatus, err );
   129             error = KErrLaunchingServer;
    99             }
   130             }*/
   100         return server;
       
   101         }
   131         }
   102         
   132         
   103     RPeninputServerImpl* self = new(ELeave) RPeninputServerImpl();
   133     RPeninputServerImpl* self = new(ELeave) RPeninputServerImpl();
   104     CleanupStack::PushL(self);
   134     CleanupStack::PushL(self);
   105     self->ConstructL(KSingletonClientId,aStatus);
   135     self->ConstructL(KSingletonClientId);
   106     CleanupStack::Pop(self);
   136     CleanupStack::Pop(self);
   107     return self;
   137     return self;
   108     }
   138     }
   109 
   139 
   110 // ---------------------------------------------------------------------------
   140 // ---------------------------------------------------------------------------
   115     {
   145     {
   116     iObserver = 0;
   146     iObserver = 0;
   117     iIsForegroundSession = EFalse;
   147     iIsForegroundSession = EFalse;
   118     iServerExit = EFalse;
   148     iServerExit = EFalse;
   119     iLaunchServer = EFalse;
   149     iLaunchServer = EFalse;
       
   150     iWaitScheduler = 0;
   120     iCurPenUiType = -1; 
   151     iCurPenUiType = -1; 
       
   152     iWaitScheduler = 0; 
   121     iAppPrefferedUiMode = EPluginInputModeNone;
   153     iAppPrefferedUiMode = EPluginInputModeNone;
   122     iAutoOpenFlag = ETrue;
   154     iAutoOpenFlag = ETrue;
   123     iBackgroundCtrl = 0;
   155     iBackgroundCtrl = 0;
   124     iResourceChange = EFalse;  
   156     iResourceChange = EFalse;  
   125     iWaiterAo = NULL;
   157     }
   126     iPendingRequest = NULL;
   158 
   127     iServerReady = EFalse;
   159 void RPeninputServerImpl::ConstructL(const TUid& aUid)
   128     }
       
   129 
       
   130 void RPeninputServerImpl::ConstructL(const TUid& aUid, TRequestStatus* aStatus)
       
   131     {
   160     {
   132     CCoeStatic * obj = CCoeEnv::Static()->FindStatic(aUid);
   161     CCoeStatic * obj = CCoeEnv::Static()->FindStatic(aUid);
   133     CPenInputSingletonClient* client;
   162     CPenInputSingletonClient* client;
   134     //__ASSERT_ALWAYS(obj == NULL, User::Leave(KErrAlreadyExists));
   163     //__ASSERT_ALWAYS(obj == NULL, User::Leave(KErrAlreadyExists));
   135     if(obj)
   164     if(obj)
   139         }
   168         }
   140     else
   169     else
   141         client = new (ELeave)CPenInputSingletonClient(aUid,this);       
   170         client = new (ELeave)CPenInputSingletonClient(aUid,this);       
   142     //Note: The client is destroyed by the control environment automatically    
   171     //Note: The client is destroyed by the control environment automatically    
   143     //User::LeaveIfError(DoConnectL());
   172     //User::LeaveIfError(DoConnectL());
   144     TRAPD(err, DoConnectL(aStatus));
   173     TRAPD(err, DoConnectL());
   145     if(KErrNone != err)
   174     if(KErrNone != err)
   146         {
   175         {
   147         client->SetInvalid();
   176         client->SetInvalid();
   148         User::LeaveIfError(err);
   177         User::LeaveIfError(err);
   149         }
   178         }
   186     
   215     
   187 // ---------------------------------------------------------------------------
   216 // ---------------------------------------------------------------------------
   188 // RPeninputServerImpl::DoConnectL
   217 // RPeninputServerImpl::DoConnectL
   189 // ---------------------------------------------------------------------------
   218 // ---------------------------------------------------------------------------
   190 //
   219 //
   191 TInt RPeninputServerImpl::DoConnectL(TRequestStatus* aStatus)
   220 TInt RPeninputServerImpl::DoConnectL()
   192     { 
   221     { 
   193     iPendingRequest = aStatus;
       
   194     TInt error = KErrNone;
   222     TInt error = KErrNone;
   195     /*************** Note ************************************************/
   223     /*************** Note ************************************************/
   196     // Multi-thread case is not considered here!
   224     // Multi-thread case is not considered here!
   197     /*************** Note ************************************************/        
   225     /*************** Note ************************************************/        
   198     
   226     
   203 
   231 
   204     if( error == KErrNotFound || error == KErrServerTerminated )
   232     if( error == KErrNotFound || error == KErrServerTerminated )
   205         {
   233         {
   206         // server does not yet exist or it has terminated
   234         // server does not yet exist or it has terminated
   207         // try to create the server
   235         // try to create the server
   208         
   236         error = StartThreadL();
   209         if(!aStatus) //sync call
   237 
       
   238         if ( error == KErrNone || error == KErrAlreadyExists )
   210             {
   239             {
   211             error = StartThreadL();
   240             // creation of server successfull, or some other client thread 
   212             if(KErrNone == error)
   241             // created it first -> try to connect again
   213                 {
   242             error = CreateSession( KPeninputServerName,
   214                 error = CreateSession( KPeninputServerName,
   243                            Version(),
   215                                            Version(),
   244                            KDefaultMessageSlots );
   216                                            KDefaultMessageSlots,EIpcSession_Sharable);
       
   217                 AddObserver();
       
   218                 }
       
   219 
       
   220             }
   245             }
   221         else
   246         else
   222             {
   247             {
   223             StartThreadAsyncL();  
   248             return error;
   224             return KErrNone;
       
   225             }
   249             }
   226         }
   250         }
   227     else if ( error == KErrNone )//server alreay there
   251 
   228         {
   252     TThreadId srvThreadId;
   229         iServerReady = ETrue;
   253     if(KErrNone == error)
   230         AddObserver();	
   254         {
   231         
   255         TIpcArgs arg;        
   232         if(aStatus)
   256     
   233         	User::RequestComplete(iPendingRequest, error);
   257         TPckg<TThreadId> msg(srvThreadId);
   234         }
   258         arg.Set(KMsgSlot0,&msg);    
       
   259         SendReceive(EPeninputRequestServerThreadId,arg);
       
   260         }
       
   261     
       
   262     iServerExit = EFalse;
       
   263 	//create default observer
       
   264     /*CPeninputServerObserver* observer = CPeninputServerObserver::NewL(this,
       
   265                                                        srvThreadId,iObserver);*/
       
   266     if(iObserver)
       
   267         {
       
   268         iObserver->ReConstructL(srvThreadId);
       
   269         }
       
   270     else
       
   271         {
       
   272         iObserver = CPeninputServerObserver::NewL(this,srvThreadId);
       
   273         }
       
   274 
       
   275     
       
   276     TFindThread findPeninputServer( _L("*peninputserver*") );
       
   277     TFullName name;
       
   278     if (findPeninputServer.Next( name ) == KErrNone)
       
   279         {
       
   280         // if server is already running return immediately
       
   281         //return KErrAlreadyExists;
       
   282         RThread p;
       
   283         TInt r = p.Open(name);
       
   284         p.Close();
       
   285         } 
       
   286     
   235     return error;
   287     return error;
   236     }
   288     }
   237 
   289 
   238 void RPeninputServerImpl::AddObserver()
       
   239     {
       
   240     TThreadId srvThreadId;
       
   241 	TIpcArgs arg;        
       
   242 
       
   243 	TPckg<TThreadId> msg(srvThreadId);
       
   244 	arg.Set(KMsgSlot0,&msg);    
       
   245 	SendReceive(EPeninputRequestServerThreadId,arg);
       
   246 
       
   247     iServerExit = EFalse;
       
   248     if(iObserver)
       
   249         {
       
   250         TRAP_IGNORE(iObserver->ReConstructL(srvThreadId));
       
   251         }
       
   252     else
       
   253         {
       
   254         TRAP_IGNORE(iObserver = CPeninputServerObserver::NewL(this,srvThreadId));
       
   255         }
       
   256     }
       
   257 
       
   258 TBool RPeninputServerImpl::ServerReady() 
       
   259 	{ 
       
   260 	return iServerReady;
       
   261 	}
       
   262 
   290 
   263 // ---------------------------------------------------------------------------
   291 // ---------------------------------------------------------------------------
   264 // RPeninputServerImpl::Version
   292 // RPeninputServerImpl::Version
   265 // ---------------------------------------------------------------------------
   293 // ---------------------------------------------------------------------------
   266 //
   294 //
   329         }
   357         }
   330    
   358    
   331     if(aFlag)
   359     if(aFlag)
   332         {
   360         {
   333         //show the background control
   361         //show the background control
   334         if(!iBackgroundCtrl && bmpHandle != -1)
   362         if(!iBackgroundCtrl)
   335             {
   363             {
   336             iBackgroundCtrl = CPenUiBackgroundWnd::NewL(CCoeEnv::Static()->RootWin(),bmpHandle);
   364             iBackgroundCtrl = CPenUiBackgroundWnd::NewL(CCoeEnv::Static()->RootWin(),bmpHandle);
   337             }
   365             }
   338         if(iBackgroundCtrl)
   366         if(iBackgroundCtrl)
   339             iBackgroundCtrl->Show(extend, iGlobalNotes, 
   367             iBackgroundCtrl->Show(extend, iGlobalNotes, 
   340                 iInternalPopup,priority, iResourceChange, iDataQueryIsPopped);    
   368                 iInternalPopup,priority, iResourceChange);    
   341         }
   369         }
   342     else //undim the window
   370     else //undim the window
   343         {
   371         {
   344         if(iBackgroundCtrl)
   372         if(iBackgroundCtrl)
   345 #ifdef FIX_FOR_NGA
   373             iBackgroundCtrl->Hide();    
   346             {
       
   347             delete iBackgroundCtrl;
       
   348             iBackgroundCtrl = 0;
       
   349             }
       
   350 #else            
       
   351             {
       
   352             iBackgroundCtrl->Hide();
       
   353             }
       
   354 #endif   
       
   355         }
   374         }
   356     }
   375     }
   357 // ---------------------------------------------------------------------------
   376 // ---------------------------------------------------------------------------
   358 // RPeninputServerImpl::ActivateLayout
   377 // RPeninputServerImpl::ActivateLayout
   359 // Activate/Deactivate a ui layout
   378 // Activate/Deactivate a ui layout
   612     
   631     
   613 // ---------------------------------------------------------------------------
   632 // ---------------------------------------------------------------------------
   614 // RPeninputServerImpl::IsDimmed
   633 // RPeninputServerImpl::IsDimmed
   615 // ---------------------------------------------------------------------------
   634 // ---------------------------------------------------------------------------
   616 //
   635 //
   617 TInt RPeninputServerImpl::SupportInputMode( TInt aLanguage )
   636 TInt RPeninputServerImpl::SupportInputMode()
   618     {
   637     {
   619     TInt supportMode = 0;
   638     TInt supportMode = 0;
   620     TIpcArgs arg;        
   639     TIpcArgs arg;        
   621     
   640     
   622     TPckg<TInt> msg(supportMode);
   641     TPckg<TInt> msg(supportMode);
   623     arg.Set(KMsgSlot0,&msg);
   642     arg.Set(KMsgSlot0,&msg);    
   624     
       
   625     TPckg<TInt> language( aLanguage );
       
   626     arg.Set( KMsgSlot1,&language );
       
   627     SendReceive(EPeninputRequestSupportInputMode,arg);
   643     SendReceive(EPeninputRequestSupportInputMode,arg);
   628 
   644 
   629     return supportMode;
   645     return supportMode;
   630     }    
   646     }    
   631     
   647     
   632 TInt RPeninputServerImpl::SetInputLanguage( TInt aLanguage )
       
   633 	{
       
   634 	TIpcArgs arg; 
       
   635 	TPckgC<TInt> msg(aLanguage);
       
   636 	arg.Set(KMsgSlot0,&msg); 
       
   637 	return SendReceive(EPeninputRequestSetInputLanguage, arg);
       
   638 	}
       
   639 
       
   640 void RPeninputServerImpl::BackgroudDefaultOri( TInt aOri )   
   648 void RPeninputServerImpl::BackgroudDefaultOri( TInt aOri )   
   641     {
   649     {
   642     TIpcArgs arg;    
   650     TIpcArgs arg;    
   643     TPckgC<TInt> msg(aOri);
   651     TPckgC<TInt> msg(aOri);
   644     arg.Set(KMsgSlot0,&msg);
   652     arg.Set(KMsgSlot0,&msg);
   662     commandLine->SetProcessEnvironmentL(aServer);
   670     commandLine->SetProcessEnvironmentL(aServer);
   663     CleanupStack::PopAndDestroy(commandLine);
   671     CleanupStack::PopAndDestroy(commandLine);
   664     
   672     
   665     }
   673     }
   666   */  
   674   */  
   667 
       
   668 TInt RPeninputServerImpl::StartThreadAsyncL()
       
   669 	{
       
   670 	//ASSERT_DUBUG(!iWaiterAo)
       
   671 	iWaiterAo = new CWaitingServerAo(this);
       
   672 	
       
   673 	
       
   674 	TInt ret = KErrNone;
       
   675 	
       
   676 	RProcess server;
       
   677 	User::LeaveIfError(server.Create(KPeninputServerExe,KNullDesC()));
       
   678 	
       
   679 	
       
   680 	server.Rendezvous(iWaiterAo->RequestStatus());
       
   681 	server.Resume();
       
   682 	server.Close();
       
   683 										   
       
   684 	return ret;
       
   685 	}
       
   686 
       
   687 
       
   688 // ---------------------------------------------------------------------------
   675 // ---------------------------------------------------------------------------
   689 // RPeninputServerImpl::StartThread
   676 // RPeninputServerImpl::StartThread
   690 // Creates the server thread on WINS and server process on MARM.
   677 // Creates the server thread on WINS and server process on MARM.
   691 // Access to the thread/process creation is controlled with 
   678 // Access to the thread/process creation is controlled with 
   692 // a global mutex which allows only one client thread to do
   679 // a global mutex which allows only one client thread to do
   695 // already created it.
   682 // already created it.
   696 // ---------------------------------------------------------------------------
   683 // ---------------------------------------------------------------------------
   697 //
   684 //
   698 TInt RPeninputServerImpl::StartThreadL()
   685 TInt RPeninputServerImpl::StartThreadL()
   699     {
   686     {
       
   687     if(iWaitScheduler)
       
   688         return KErrLaunchingServer;
   700     TInt ret = KErrNone;
   689     TInt ret = KErrNone;
       
   690 
       
   691     // check if server already exists
       
   692     TFindServer findPeninputServer( KPeninputServerName );
       
   693     TFullName name;
       
   694     if (findPeninputServer.Next( name ) == KErrNone)
       
   695         {
       
   696         // if server is already running return immediately
       
   697         return KErrAlreadyExists;
       
   698         } 
       
   699     // request status which gets signaled when server has been initialized
   701 
   700 
   702     RProcess server;
   701     RProcess server;
   703     User::LeaveIfError(server.Create(KPeninputServerExe,KNullDesC()));
   702     User::LeaveIfError(server.Create(KPeninputServerExe,KNullDesC()));
   704     
   703     TRequestStatus status;            
   705     TRequestStatus status;
   704     //User::WaitForRequest(status);
   706     server.Rendezvous(status);
   705     
       
   706     
       
   707     iObserver = CPeninputServerObserver::NewL(this,
       
   708                                                0);
       
   709     server.Rendezvous(iObserver->RequestStatus());
   707     server.Resume();
   710     server.Resume();
   708     server.Close();
   711     server.Close();
   709     
   712                                                
   710     User::WaitForRequest(status);
   713     iWaitScheduler = CPeninputServerWaiter::NewL(); 
   711     if(ESignalServerReady != status.Int())
   714     iWaitScheduler->Start();
   712         ret = KErrGeneral;
   715     ret = iWaitScheduler->Error();
   713     else
   716     
   714         iServerReady = ETrue;     
       
   715     return ret;
   717     return ret;
   716     }
   718     }
   717 
       
   718 
   719 
   719 // ---------------------------------------------------------------------------
   720 // ---------------------------------------------------------------------------
   720 // RPeninputServerImpl::AddPeninputServerObserverL
   721 // RPeninputServerImpl::AddPeninputServerObserverL
   721 // Add observer
   722 // Add observer
   722 // ---------------------------------------------------------------------------
   723 // ---------------------------------------------------------------------------
   893 // Read buffer
   894 // Read buffer
   894 // ---------------------------------------------------------------------------
   895 // ---------------------------------------------------------------------------
   895 //
   896 //
   896 void RPeninputServerImpl::ReadIntArrayFromBufL(const TDesC8& aBuf, RArray<TInt>& aResult)
   897 void RPeninputServerImpl::ReadIntArrayFromBufL(const TDesC8& aBuf, RArray<TInt>& aResult)
   897     {
   898     {
   898 	CleanupClosePushL( aResult );
       
   899 	RDesReadStream readStream;
   899 	RDesReadStream readStream;
   900 	readStream.Open(aBuf);
   900 	readStream.Open(aBuf);
   901 	CleanupClosePushL(readStream);
   901 	CleanupClosePushL(readStream);
   902 	const TInt entryCount = readStream.ReadInt32L();
   902 	const TInt entryCount = readStream.ReadInt32L();
   903 
   903 
   905 		{
   905 		{
   906 		aResult.AppendL(readStream.ReadInt32L());
   906 		aResult.AppendL(readStream.ReadInt32L());
   907 		}
   907 		}
   908 		
   908 		
   909     CleanupStack::PopAndDestroy(&readStream);
   909     CleanupStack::PopAndDestroy(&readStream);
   910     CleanupStack::Pop( &aResult );
       
   911     }
   910     }
   912 
   911 
   913 // ---------------------------------------------------------------------------
   912 // ---------------------------------------------------------------------------
   914 // RPeninputServerImpl::SetForeground
   913 // RPeninputServerImpl::SetForeground
   915 // Set current session to be foreground application session
   914 // Set current session to be foreground application session
   973     arg.Set(KMsgSlot0,&msg);         
   972     arg.Set(KMsgSlot0,&msg);         
   974     
   973     
   975     iSingletonServer->SendReceive(EPeninputRequestAddUiObserver,arg);        
   974     iSingletonServer->SendReceive(EPeninputRequestAddUiObserver,arg);        
   976     
   975     
   977     }
   976     }
   978   */
   977   */  
   979 /*
       
   980 void RPeninputServerImpl::OnServerReady( TBool aFlag)    
   978 void RPeninputServerImpl::OnServerReady( TBool aFlag)    
   981    {
   979     {
   982     //iLaunchServer = EFalse;
   980     //iLaunchServer = EFalse;
   983     
   981     
       
   982     iWaitScheduler->Stop(aFlag);//AsyncStop();
   984     //if(iPenUiNotificationHandler)
   983     //if(iPenUiNotificationHandler)
   985       // DoAddPenUiActivationHandler(); 
   984       // DoAddPenUiActivationHandler(); 
   986     }*/
   985     }
   987 // ---------------------------------------------------------------------------
   986 // ---------------------------------------------------------------------------
   988 // RPeninputServerImpl::AddPenUiActivationHandler
   987 // RPeninputServerImpl::AddPenUiActivationHandler
   989 // Add an UI activate/deactivation handler
   988 // Add an UI activate/deactivation handler
   990 // ---------------------------------------------------------------------------
   989 // ---------------------------------------------------------------------------
   991 //
   990 //
  1060 
  1059 
  1061 void RPeninputServerImpl::FinalClose()
  1060 void RPeninputServerImpl::FinalClose()
  1062     {
  1061     {
  1063     delete iBackgroundCtrl;  
  1062     delete iBackgroundCtrl;  
  1064       
  1063       
       
  1064     delete iWaitScheduler;
       
  1065     iWaitScheduler = 0;
  1065     iPenUiNotificationHandler.Close();
  1066     iPenUiNotificationHandler.Close();
  1066     delete iObserver;
  1067     delete iObserver;
  1067     iObserver = NULL;
  1068     iObserver = NULL;
  1068     
       
  1069     if ( iWaiterAo )
       
  1070     	{
       
  1071 		iWaiterAo->Cancel();
       
  1072 		delete iWaiterAo;
       
  1073 		iWaiterAo = NULL;
       
  1074     	}
       
  1075     
  1069     
  1076     RSessionBase::Close();    
  1070     RSessionBase::Close();    
  1077     }
  1071     }
  1078     
  1072     
  1079     
  1073     
  1121 void RPeninputServerImpl::SetGlobalNotes(TBool aFlag)
  1115 void RPeninputServerImpl::SetGlobalNotes(TBool aFlag)
  1122     {
  1116     {
  1123     iGlobalNotes = aFlag;    
  1117     iGlobalNotes = aFlag;    
  1124     }
  1118     }
  1125 
  1119 
  1126 void RPeninputServerImpl::SetDataQueryPopped(TBool aFlag)
       
  1127 	{
       
  1128 	iDataQueryIsPopped = aFlag;
       
  1129 	}
       
  1130 void RPeninputServerImpl::SetInternalPopUp(TBool aFlag)
  1120 void RPeninputServerImpl::SetInternalPopUp(TBool aFlag)
  1131     {
  1121     {
  1132 	iInternalPopup = aFlag;
  1122 	iInternalPopup = aFlag;
  1133     } 
  1123     } 
  1134     
  1124     
  1156     
  1146     
  1157     TPckg<TBool> msg(bChange);
  1147     TPckg<TBool> msg(bChange);
  1158     arg.Set(KMsgSlot0,&msg);    
  1148     arg.Set(KMsgSlot0,&msg);    
  1159     SendReceive(EPeninputRequestDimResChangeLayout,arg);       
  1149     SendReceive(EPeninputRequestDimResChangeLayout,arg);       
  1160     }
  1150     }
  1161 
       
  1162 void RPeninputServerImpl::EnablePriorityChangeOnOriChange(TBool aEnabled)
       
  1163     {
       
  1164 	TIpcArgs arg;
       
  1165 	TPckg<TBool> msg(aEnabled);
       
  1166     arg.Set(KMsgSlot0,&msg); 
       
  1167 	SendReceive(EPeninputEnablePriorityChangeOnOriChange,arg); 
       
  1168 	}
       
  1169     
  1151     
  1170 //end of class RPeninputServerImpl
  1152 //end of class RPeninputServerImpl
  1171 
  1153 
  1172 
  1154 
  1173 // Class CPeninputServerObserver
  1155 // Class CPeninputServerObserver
  1268         TInt exitReason = 0;
  1250         TInt exitReason = 0;
  1269         if(err == KErrNone) //thread is just closed
  1251         if(err == KErrNone) //thread is just closed
  1270             {
  1252             {
  1271             exitReason = srvThread.ExitReason();        
  1253             exitReason = srvThread.ExitReason();        
  1272             srvThread.Close();
  1254             srvThread.Close();
  1273             //iPeninputServer->OnServerReady(-1000);
  1255             iPeninputServer->OnServerReady(-1000);
  1274             }
  1256             }
  1275         if(err != KErrNone || exitReason != 0) //server has exited
  1257         if(err != KErrNone || exitReason != 0) //server has exited
  1276             {
  1258             {
  1277             iServerExit  = ETrue;
  1259             iServerExit  = ETrue;
  1278             iPeninputServer->HandleServerExit();             
  1260             iPeninputServer->HandleServerExit();             
  1281             }
  1263             }
  1282         }
  1264         }
  1283 
  1265 
  1284     if(iStatus.Int() == ESignalServerReady) //server has started
  1266     if(iStatus.Int() == ESignalServerReady) //server has started
  1285         {
  1267         {
  1286         //iPeninputServer->OnServerReady();
  1268         iPeninputServer->OnServerReady();
  1287         return;
  1269         return;
  1288         }
  1270         }
  1289     //if there is also iUiActivationHandler, handle it first
  1271     //if there is also iUiActivationHandler, handle it first
  1290     if(iUiActivationHandler)
  1272     if(iUiActivationHandler)
  1291     	ret = iUiActivationHandler->HandleServerEventL(iStatus.Int());
  1273     	ret = iUiActivationHandler->HandleServerEventL(iStatus.Int());
  1457     TBool b = IsNonFocusing();
  1439     TBool b = IsNonFocusing();
  1458     SetFocusing(EFalse);
  1440     SetFocusing(EFalse);
  1459     }
  1441     }
  1460 
  1442 
  1461 void CPenUiBackgroundWnd::Show(const TRect& aExtend, TBool aGlobalNotes, 
  1443 void CPenUiBackgroundWnd::Show(const TRect& aExtend, TBool aGlobalNotes, 
  1462     TBool aInternal, TInt aPriority, TBool aResource, TBool aDataQueryPopped)
  1444     TBool aInternal, TInt aPriority, TBool aResource)
  1463     {
  1445     {
  1464     //Show the window will cause a focus group change in global notes showing case.
  1446     //Show the window will cause a focus group change in global notes showing case.
  1465     if (!iBitmap)
  1447     if (!iBitmap)
  1466         {
  1448         {
  1467         return;    
  1449         return;    
  1488         
  1470         
  1489         iWndGroup.SetOrdinalPosition( 0, aPriority); 
  1471         iWndGroup.SetOrdinalPosition( 0, aPriority); 
  1490 
  1472 
  1491         Window().SetOrdinalPosition(0,aPriority);      
  1473         Window().SetOrdinalPosition(0,aPriority);      
  1492      
  1474      
  1493         // The code runs well on 5.0 platform, but on tb92,
  1475         Window().SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly);
  1494         // it will make the backgourd screen black purely.
       
  1495         if( aDataQueryPopped )
       
  1496         	{
       
  1497             Window().SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly);  
       
  1498         	}
       
  1499         }
  1476         }
  1500      else
  1477      else
  1501         {
  1478         {
  1502         Window().SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly);
  1479         Window().SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly);    
  1503         }
  1480         }
  1504  
  1481  
  1505     Window().Invalidate();
  1482     Window().Invalidate();
  1506     DrawNow();
  1483     DrawNow();
  1507     }
  1484     }
  1520 void CPenUiBackgroundWnd::Hide()
  1497 void CPenUiBackgroundWnd::Hide()
  1521     {
  1498     {
  1522     MakeVisible( EFalse );
  1499     MakeVisible( EFalse );
  1523     }
  1500     }
  1524 
  1501 
  1525 
       
  1526 void RPeninputServerImpl::OnServerStarted(TInt aErr)
       
  1527     {
       
  1528     if(KErrNone == aErr)
       
  1529         {
       
  1530         iServerReady = ETrue;
       
  1531         
       
  1532         //create session
       
  1533         aErr = CreateSession( KPeninputServerName,
       
  1534                            Version(),
       
  1535                            KDefaultMessageSlots,EIpcSession_Sharable);
       
  1536 
       
  1537 	    if(KErrNone == aErr)
       
  1538 	    	{
       
  1539 	        AddObserver();
       
  1540 	    	}
       
  1541         }
       
  1542     User::RequestComplete(iPendingRequest, aErr);
       
  1543     }
       
  1544 
       
  1545 CWaitingServerAo::CWaitingServerAo(RPeninputServerImpl* aClient) 
       
  1546                 : CActive(CActive::EPriorityStandard),
       
  1547                   iClient(aClient)
       
  1548     {
       
  1549     CActiveScheduler::Add(this);
       
  1550     SetActive();
       
  1551     iStatus = KRequestPending;
       
  1552     }
       
  1553 
       
  1554 
       
  1555 void CWaitingServerAo::RunL()
       
  1556     {
       
  1557     TInt err = ESignalServerReady == iStatus.Int() ? KErrNone : KErrGeneral;
       
  1558 
       
  1559     iClient->OnServerStarted(err);
       
  1560     }
       
  1561 
       
  1562 void CWaitingServerAo::DoCancel()
       
  1563     {
       
  1564     }
       
  1565 TInt CWaitingServerAo::RunError(TInt /*aError*/)
       
  1566     {
       
  1567     return KErrNone;
       
  1568     }
       
  1569 
       
  1570 TRequestStatus& CWaitingServerAo::RequestStatus()
       
  1571     {
       
  1572     return iStatus;
       
  1573     }
       
  1574 // End of File
  1502 // End of File
  1575 
  1503