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