--- a/textinput/peninputarc/src/peninputclient/penclientimpl.cpp Tue Aug 31 15:31:50 2010 +0300
+++ b/textinput/peninputarc/src/peninputclient/penclientimpl.cpp Wed Sep 01 12:23:33 2010 +0100
@@ -29,6 +29,9 @@
#include <coemain.h>
#include <apgwgnam.h>
#include "peninputclient.h"
+#ifndef FIX_FOR_NGA
+#define FIX_FOR_NGA
+#endif
const TUint KDefaultMessageSlots = 4;
const TInt KMaxSupportLanguages = 100;
@@ -74,47 +77,13 @@
}
-
-CPeninputServerWaiter* CPeninputServerWaiter::NewL()
- {
- CPeninputServerWaiter* self = new(ELeave)CPeninputServerWaiter;
- CleanupStack::PushL(self);
- self->ConstructL();
- CleanupStack::Pop(self);
- return self;
- }
-void CPeninputServerWaiter::ConstructL()
- {
- iWaitScheduler = new(ELeave) CActiveSchedulerWait;
- }
-
-CPeninputServerWaiter::~CPeninputServerWaiter()
- {
- delete iWaitScheduler;
- }
-
-void CPeninputServerWaiter::Start()
- {
- iWaitScheduler->Start();
- }
-
-void CPeninputServerWaiter::Stop(TInt aFlag)
- {
- //if(aFlag)
- iError = aFlag ? KErrNone : aFlag;
-
- iWaitScheduler->AsyncStop();
- }
-
-
-
// ======== MEMBER FUNCTIONS ========
// ---------------------------------------------------------------------------
// RPeninputServerImpl::NewL
// ---------------------------------------------------------------------------
//
-RPeninputServerImpl* RPeninputServerImpl::NewL()
+RPeninputServerImpl* RPeninputServerImpl::NewL(TRequestStatus* aStatus)
{
//check for singleton existence
CCoeStatic * obj = CCoeEnv::Static()->FindStatic(KSingletonClientId);
@@ -123,16 +92,17 @@
if(client && client->IsValid())
{
RPeninputServerImpl* server = client->GetSingletonServer();
- return server;
-/* if(iSingletonServer == 0 ) // second or later connecting from same client
+ TInt err = server->ServerReady() ? KErrNone : KErrLaunchingServer;
+ if ( aStatus )
{
- error = KErrLaunchingServer;
- }*/
+ User::RequestComplete( aStatus, err );
+ }
+ return server;
}
RPeninputServerImpl* self = new(ELeave) RPeninputServerImpl();
CleanupStack::PushL(self);
- self->ConstructL(KSingletonClientId);
+ self->ConstructL(KSingletonClientId,aStatus);
CleanupStack::Pop(self);
return self;
}
@@ -147,16 +117,17 @@
iIsForegroundSession = EFalse;
iServerExit = EFalse;
iLaunchServer = EFalse;
- iWaitScheduler = 0;
iCurPenUiType = -1;
- iWaitScheduler = 0;
iAppPrefferedUiMode = EPluginInputModeNone;
iAutoOpenFlag = ETrue;
iBackgroundCtrl = 0;
iResourceChange = EFalse;
+ iWaiterAo = NULL;
+ iPendingRequest = NULL;
+ iServerReady = EFalse;
}
-void RPeninputServerImpl::ConstructL(const TUid& aUid)
+void RPeninputServerImpl::ConstructL(const TUid& aUid, TRequestStatus* aStatus)
{
CCoeStatic * obj = CCoeEnv::Static()->FindStatic(aUid);
CPenInputSingletonClient* client;
@@ -170,7 +141,7 @@
client = new (ELeave)CPenInputSingletonClient(aUid,this);
//Note: The client is destroyed by the control environment automatically
//User::LeaveIfError(DoConnectL());
- TRAPD(err, DoConnectL());
+ TRAPD(err, DoConnectL(aStatus));
if(KErrNone != err)
{
client->SetInvalid();
@@ -217,8 +188,9 @@
// RPeninputServerImpl::DoConnectL
// ---------------------------------------------------------------------------
//
-TInt RPeninputServerImpl::DoConnectL()
+TInt RPeninputServerImpl::DoConnectL(TRequestStatus* aStatus)
{
+ iPendingRequest = aStatus;
TInt error = KErrNone;
/*************** Note ************************************************/
// Multi-thread case is not considered here!
@@ -233,60 +205,60 @@
{
// server does not yet exist or it has terminated
// try to create the server
- error = StartThreadL();
-
- if ( error == KErrNone || error == KErrAlreadyExists )
+
+ if(!aStatus) //sync call
{
- // creation of server successfull, or some other client thread
- // created it first -> try to connect again
- error = CreateSession( KPeninputServerName,
- Version(),
- KDefaultMessageSlots );
+ error = StartThreadL();
+ if(KErrNone == error)
+ {
+ error = CreateSession( KPeninputServerName,
+ Version(),
+ KDefaultMessageSlots,EIpcSession_Sharable);
+ AddObserver();
+ }
+
}
else
{
- return error;
+ StartThreadAsyncL();
+ return KErrNone;
}
}
-
- TThreadId srvThreadId;
- if(KErrNone == error)
+ else if ( error == KErrNone )//server alreay there
{
- TIpcArgs arg;
-
- TPckg<TThreadId> msg(srvThreadId);
- arg.Set(KMsgSlot0,&msg);
- SendReceive(EPeninputRequestServerThreadId,arg);
+ iServerReady = ETrue;
+ AddObserver();
+
+ if(aStatus)
+ User::RequestComplete(iPendingRequest, error);
}
-
+ return error;
+ }
+
+void RPeninputServerImpl::AddObserver()
+ {
+ TThreadId srvThreadId;
+ TIpcArgs arg;
+
+ TPckg<TThreadId> msg(srvThreadId);
+ arg.Set(KMsgSlot0,&msg);
+ SendReceive(EPeninputRequestServerThreadId,arg);
+
iServerExit = EFalse;
- //create default observer
- /*CPeninputServerObserver* observer = CPeninputServerObserver::NewL(this,
- srvThreadId,iObserver);*/
if(iObserver)
{
- iObserver->ReConstructL(srvThreadId);
+ TRAP_IGNORE(iObserver->ReConstructL(srvThreadId));
}
else
{
- iObserver = CPeninputServerObserver::NewL(this,srvThreadId);
+ TRAP_IGNORE(iObserver = CPeninputServerObserver::NewL(this,srvThreadId));
}
-
-
- TFindThread findPeninputServer( _L("*peninputserver*") );
- TFullName name;
- if (findPeninputServer.Next( name ) == KErrNone)
- {
- // if server is already running return immediately
- //return KErrAlreadyExists;
- RThread p;
- TInt r = p.Open(name);
- p.Close();
- }
-
- return error;
}
+TBool RPeninputServerImpl::ServerReady()
+ {
+ return iServerReady;
+ }
// ---------------------------------------------------------------------------
// RPeninputServerImpl::Version
@@ -359,18 +331,27 @@
if(aFlag)
{
//show the background control
- if(!iBackgroundCtrl)
+ if(!iBackgroundCtrl && bmpHandle != -1)
{
iBackgroundCtrl = CPenUiBackgroundWnd::NewL(CCoeEnv::Static()->RootWin(),bmpHandle);
}
if(iBackgroundCtrl)
iBackgroundCtrl->Show(extend, iGlobalNotes,
- iInternalPopup,priority, iResourceChange);
+ iInternalPopup,priority, iResourceChange, iDataQueryIsPopped);
}
else //undim the window
{
if(iBackgroundCtrl)
- iBackgroundCtrl->Hide();
+#ifdef FIX_FOR_NGA
+ {
+ delete iBackgroundCtrl;
+ iBackgroundCtrl = 0;
+ }
+#else
+ {
+ iBackgroundCtrl->Hide();
+ }
+#endif
}
}
// ---------------------------------------------------------------------------
@@ -633,18 +614,29 @@
// RPeninputServerImpl::IsDimmed
// ---------------------------------------------------------------------------
//
-TInt RPeninputServerImpl::SupportInputMode()
+TInt RPeninputServerImpl::SupportInputMode( TInt aLanguage )
{
TInt supportMode = 0;
TIpcArgs arg;
TPckg<TInt> msg(supportMode);
- arg.Set(KMsgSlot0,&msg);
+ arg.Set(KMsgSlot0,&msg);
+
+ TPckg<TInt> language( aLanguage );
+ arg.Set( KMsgSlot1,&language );
SendReceive(EPeninputRequestSupportInputMode,arg);
return supportMode;
}
+TInt RPeninputServerImpl::SetInputLanguage( TInt aLanguage )
+ {
+ TIpcArgs arg;
+ TPckgC<TInt> msg(aLanguage);
+ arg.Set(KMsgSlot0,&msg);
+ return SendReceive(EPeninputRequestSetInputLanguage, arg);
+ }
+
void RPeninputServerImpl::BackgroudDefaultOri( TInt aOri )
{
TIpcArgs arg;
@@ -672,6 +664,27 @@
}
*/
+
+TInt RPeninputServerImpl::StartThreadAsyncL()
+ {
+ //ASSERT_DUBUG(!iWaiterAo)
+ iWaiterAo = new CWaitingServerAo(this);
+
+
+ TInt ret = KErrNone;
+
+ RProcess server;
+ User::LeaveIfError(server.Create(KPeninputServerExe,KNullDesC()));
+
+
+ server.Rendezvous(iWaiterAo->RequestStatus());
+ server.Resume();
+ server.Close();
+
+ return ret;
+ }
+
+
// ---------------------------------------------------------------------------
// RPeninputServerImpl::StartThread
// Creates the server thread on WINS and server process on MARM.
@@ -684,39 +697,25 @@
//
TInt RPeninputServerImpl::StartThreadL()
{
- if(iWaitScheduler)
- return KErrLaunchingServer;
TInt ret = KErrNone;
- // check if server already exists
- TFindServer findPeninputServer( KPeninputServerName );
- TFullName name;
- if (findPeninputServer.Next( name ) == KErrNone)
- {
- // if server is already running return immediately
- return KErrAlreadyExists;
- }
- // request status which gets signaled when server has been initialized
-
RProcess server;
User::LeaveIfError(server.Create(KPeninputServerExe,KNullDesC()));
- TRequestStatus status;
- //User::WaitForRequest(status);
-
- iObserver = CPeninputServerObserver::NewL(this,
- 0);
- server.Rendezvous(iObserver->RequestStatus());
+ TRequestStatus status;
+ server.Rendezvous(status);
server.Resume();
server.Close();
-
- iWaitScheduler = CPeninputServerWaiter::NewL();
- iWaitScheduler->Start();
- ret = iWaitScheduler->Error();
+ User::WaitForRequest(status);
+ if(ESignalServerReady != status.Int())
+ ret = KErrGeneral;
+ else
+ iServerReady = ETrue;
return ret;
}
+
// ---------------------------------------------------------------------------
// RPeninputServerImpl::AddPeninputServerObserverL
// Add observer
@@ -896,6 +895,7 @@
//
void RPeninputServerImpl::ReadIntArrayFromBufL(const TDesC8& aBuf, RArray<TInt>& aResult)
{
+ CleanupClosePushL( aResult );
RDesReadStream readStream;
readStream.Open(aBuf);
CleanupClosePushL(readStream);
@@ -907,6 +907,7 @@
}
CleanupStack::PopAndDestroy(&readStream);
+ CleanupStack::Pop( &aResult );
}
// ---------------------------------------------------------------------------
@@ -974,15 +975,15 @@
iSingletonServer->SendReceive(EPeninputRequestAddUiObserver,arg);
}
- */
+ */
+/*
void RPeninputServerImpl::OnServerReady( TBool aFlag)
- {
+ {
//iLaunchServer = EFalse;
- iWaitScheduler->Stop(aFlag);//AsyncStop();
//if(iPenUiNotificationHandler)
// DoAddPenUiActivationHandler();
- }
+ }*/
// ---------------------------------------------------------------------------
// RPeninputServerImpl::AddPenUiActivationHandler
// Add an UI activate/deactivation handler
@@ -1061,12 +1062,17 @@
{
delete iBackgroundCtrl;
- delete iWaitScheduler;
- iWaitScheduler = 0;
iPenUiNotificationHandler.Close();
delete iObserver;
iObserver = NULL;
+ if ( iWaiterAo )
+ {
+ iWaiterAo->Cancel();
+ delete iWaiterAo;
+ iWaiterAo = NULL;
+ }
+
RSessionBase::Close();
}
@@ -1117,6 +1123,10 @@
iGlobalNotes = aFlag;
}
+void RPeninputServerImpl::SetDataQueryPopped(TBool aFlag)
+ {
+ iDataQueryIsPopped = aFlag;
+ }
void RPeninputServerImpl::SetInternalPopUp(TBool aFlag)
{
iInternalPopup = aFlag;
@@ -1148,6 +1158,14 @@
arg.Set(KMsgSlot0,&msg);
SendReceive(EPeninputRequestDimResChangeLayout,arg);
}
+
+void RPeninputServerImpl::EnablePriorityChangeOnOriChange(TBool aEnabled)
+ {
+ TIpcArgs arg;
+ TPckg<TBool> msg(aEnabled);
+ arg.Set(KMsgSlot0,&msg);
+ SendReceive(EPeninputEnablePriorityChangeOnOriChange,arg);
+ }
//end of class RPeninputServerImpl
@@ -1252,7 +1270,7 @@
{
exitReason = srvThread.ExitReason();
srvThread.Close();
- iPeninputServer->OnServerReady(-1000);
+ //iPeninputServer->OnServerReady(-1000);
}
if(err != KErrNone || exitReason != 0) //server has exited
{
@@ -1265,7 +1283,7 @@
if(iStatus.Int() == ESignalServerReady) //server has started
{
- iPeninputServer->OnServerReady();
+ //iPeninputServer->OnServerReady();
return;
}
//if there is also iUiActivationHandler, handle it first
@@ -1441,7 +1459,7 @@
}
void CPenUiBackgroundWnd::Show(const TRect& aExtend, TBool aGlobalNotes,
- TBool aInternal, TInt aPriority, TBool aResource)
+ TBool aInternal, TInt aPriority, TBool aResource, TBool aDataQueryPopped)
{
//Show the window will cause a focus group change in global notes showing case.
if (!iBitmap)
@@ -1472,11 +1490,16 @@
Window().SetOrdinalPosition(0,aPriority);
- Window().SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly);
+ // The code runs well on 5.0 platform, but on tb92,
+ // it will make the backgourd screen black purely.
+ if( aDataQueryPopped )
+ {
+ Window().SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly);
+ }
}
else
{
- Window().SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly);
+ Window().SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly);
}
Window().Invalidate();
@@ -1499,5 +1522,54 @@
MakeVisible( EFalse );
}
+
+void RPeninputServerImpl::OnServerStarted(TInt aErr)
+ {
+ if(KErrNone == aErr)
+ {
+ iServerReady = ETrue;
+
+ //create session
+ aErr = CreateSession( KPeninputServerName,
+ Version(),
+ KDefaultMessageSlots,EIpcSession_Sharable);
+
+ if(KErrNone == aErr)
+ {
+ AddObserver();
+ }
+ }
+ User::RequestComplete(iPendingRequest, aErr);
+ }
+
+CWaitingServerAo::CWaitingServerAo(RPeninputServerImpl* aClient)
+ : CActive(CActive::EPriorityStandard),
+ iClient(aClient)
+ {
+ CActiveScheduler::Add(this);
+ SetActive();
+ iStatus = KRequestPending;
+ }
+
+
+void CWaitingServerAo::RunL()
+ {
+ TInt err = ESignalServerReady == iStatus.Int() ? KErrNone : KErrGeneral;
+
+ iClient->OnServerStarted(err);
+ }
+
+void CWaitingServerAo::DoCancel()
+ {
+ }
+TInt CWaitingServerAo::RunError(TInt /*aError*/)
+ {
+ return KErrNone;
+ }
+
+TRequestStatus& CWaitingServerAo::RequestStatus()
+ {
+ return iStatus;
+ }
// End of File