devicemgmtnotifications/dmdevdialogclient/src/dmdevdialogclient.cpp
changeset 73 ae69c2e8bc34
parent 51 2e64dc50f295
--- a/devicemgmtnotifications/dmdevdialogclient/src/dmdevdialogclient.cpp	Tue Sep 28 17:53:08 2010 +0530
+++ b/devicemgmtnotifications/dmdevdialogclient/src/dmdevdialogclient.cpp	Fri Oct 15 11:46:45 2010 +0530
@@ -55,17 +55,24 @@
 	{	
 	FLOG(_L("RDmDevDialog::OpenL()- Begin"));
 	TInt res = KErrNone;
-		FLOG(_L("RDmDevDialog::OpenL()- Secured client"));
-		res = CreateSession( KDMDEVDIALOGSERVER,TVersion(KDmDevDialogServerVersionMajor,
+	FLOG(_L("RDmDevDialog::OpenL()- Secured client"));		
+	const int maxRetry(4);
+	TInt retry = maxRetry;
+	do {
+        res = CreateSession( KDMDEVDIALOGSERVER,TVersion(KDmDevDialogServerVersionMajor,
 		        KDmDevDialogServerVersionMinor,0),KDefaultMessageSlots );
-		if ( res != KErrNone )
-			{
-			FLOG(_L("RDmDevDialog::OpenL()- session not created"));
-			res = StartServerL();
-			User::LeaveIfError( res );
-			res = CreateSession( KDMDEVDIALOGSERVER,TVersion(KDmDevDialogServerVersionMajor,
+        if (KErrNotFound != res && KErrServerTerminated != res) {
+            retry =0;
+        } else {
+            TRAP(res, StartServerL());
+            if (KErrNone == res || KErrAlreadyExists == res) {
+                retry =0;
+                res = CreateSession( KDMDEVDIALOGSERVER,TVersion(KDmDevDialogServerVersionMajor,
 	                KDmDevDialogServerVersionMinor,0),KDefaultMessageSlots );
-			}							
+            }
+        }
+    } while (--retry > 0);
+	User::LeaveIfError( res );		
 	FLOG(_L("RDmDevDialog::OpenL()- End %d"),res);	
 	return res;
 	}