44 #include "xqservicemetadata/xqservicemetadata_p.h" |
44 #include "xqservicemetadata/xqservicemetadata_p.h" |
45 #include <xqservicemetadata/xqaiwinterfacedescriptor.h> |
45 #include <xqservicemetadata/xqaiwinterfacedescriptor.h> |
46 #include "xqconversions.h" |
46 #include "xqconversions.h" |
47 |
47 |
48 |
48 |
49 #define TIMER_DELAY 3000 |
49 #define TIMER_DELAY 3000000 // 3000000 microseconds == 3s |
50 |
50 |
51 class CProcessInfo : public CActive |
51 class CProcessInfo : public CActive |
52 { |
52 { |
53 public: |
53 public: |
54 static void AddProcessL(const TUid& appUid, RProcess& appProcess); |
54 static void AddProcessL(const TUid& appUid, RProcess& appProcess); |
55 static void EnsureProcessCanStartL(const TUid& appUid); |
55 static bool EnsureProcessCanStartL(const TUid& appUid); |
56 |
56 |
57 protected: |
57 protected: |
58 CProcessInfo(const TUid& appUid); |
58 CProcessInfo(const TUid& appUid); |
59 ~CProcessInfo(); |
59 ~CProcessInfo(); |
60 void ConstructL(RProcess& appProcess); |
60 void ConstructL(RProcess& appProcess); |
109 CleanupStack::PushL(self); |
109 CleanupStack::PushL(self); |
110 self->ConstructL(appProcess); |
110 self->ConstructL(appProcess); |
111 CleanupStack::Pop(self); |
111 CleanupStack::Pop(self); |
112 } |
112 } |
113 |
113 |
114 void CProcessInfo::EnsureProcessCanStartL(const TUid& appUid) |
114 bool CProcessInfo::EnsureProcessCanStartL(const TUid& appUid) |
115 { |
115 { |
116 XQSERVICE_DEBUG_PRINT("CProcessInfo::EnsureProcessCanStartL"); |
116 XQSERVICE_DEBUG_PRINT("CProcessInfo::EnsureProcessCanStartL"); |
|
117 |
|
118 bool ret = true; |
117 |
119 |
118 CProcessInfo* previousProcess = iProcessInfoMap.map[appUid.iUid]; |
120 CProcessInfo* previousProcess = iProcessInfoMap.map[appUid.iUid]; |
119 if (previousProcess) { |
121 if (previousProcess) { |
120 previousProcess->Cancel(); |
|
121 |
|
122 // Timer is for ensure that wait will end. |
122 // Timer is for ensure that wait will end. |
123 // Maybe there is possibility that destroing process notification could be lost. |
123 // Maybe there is possibility that destroing process notification could be lost. |
124 RTimer securityTimer; |
124 RTimer securityTimer; |
125 securityTimer.CreateLocal(); |
125 securityTimer.CreateLocal(); |
126 CleanupClosePushL(securityTimer); |
126 CleanupClosePushL(securityTimer); |
127 |
127 |
128 TRequestStatus timerStatus; |
128 TRequestStatus timerStatus; |
129 securityTimer.After(timerStatus, TIMER_DELAY); |
129 securityTimer.After(timerStatus, TIMER_DELAY); |
130 User::WaitForRequest(previousProcess->iStatus, timerStatus); |
130 User::WaitForRequest(previousProcess->iStatus, timerStatus); |
131 |
131 |
|
132 if (previousProcess->iStatus == KRequestPending) |
|
133 ret = false; |
|
134 |
132 CleanupStack::PopAndDestroy(); |
135 CleanupStack::PopAndDestroy(); |
133 delete previousProcess; |
136 delete previousProcess; |
134 iProcessInfoMap.map.remove(appUid.iUid); |
137 iProcessInfoMap.map.remove(appUid.iUid); |
135 } |
138 } |
|
139 return ret; |
136 } |
140 } |
137 |
141 |
138 void CProcessInfo::RunL() |
142 void CProcessInfo::RunL() |
139 { |
143 { |
140 XQSERVICE_DEBUG_PRINT("CProcessInfo::RunL"); |
144 XQSERVICE_DEBUG_PRINT("CProcessInfo::RunL"); |
491 // Can not be embedded (non GUI client) |
495 // Can not be embedded (non GUI client) |
492 embed = false; |
496 embed = false; |
493 } |
497 } |
494 } |
498 } |
495 else { |
499 else { |
496 CProcessInfo::EnsureProcessCanStartL(uid); |
500 if(!CProcessInfo::EnsureProcessCanStartL(uid)) |
|
501 User::Leave(KErrAlreadyExists); |
497 } |
502 } |
498 TRequestStatus requestStatusForRendezvous; |
503 TRequestStatus requestStatusForRendezvous; |
499 |
504 |
500 // start application with command line parameters |
505 // start application with command line parameters |
501 //User::LeaveIfError( iApaSession.StartApp( *cmdLine, threadId, &requestStatusForRendezvous) ); |
506 //User::LeaveIfError( iApaSession.StartApp( *cmdLine, threadId, &requestStatusForRendezvous) ); |