commsconfig/commsdatabaseshim/commdbshim/Notifier/src/NotifyClient.CPP
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @deprecated since v9.1. Functionality is replaced with commsdat.
       
    19 */
       
    20 
       
    21 #include "NotifyClient.H"
       
    22 #include "NotifierServ.H"
       
    23 
       
    24 const TInt KCommsDatServerMaxOuterLoopRetryCount=2;
       
    25 const TInt KCommsDatServerMaxInnerLoopRetryCount=10;
       
    26 const TInt KCommsDatServerRetryTimeout=200000;	// 200 msec
       
    27 
       
    28 //**********************************
       
    29 //RCommsdatNotifier
       
    30 //**********************************
       
    31 
       
    32 EXPORT_C RCommsdatNotifier::RCommsdatNotifier()
       
    33 	/** Constructor. */
       
    34 	{}
       
    35 
       
    36 		
       
    37 TInt RCommsdatNotifier::StartNotifierProcess()
       
    38 	{	
       
    39 	RProcess server;
       
    40 	
       
    41 	TInt ret=server.Create(KCommsdatNotifierExecutable, KNullDesC);
       
    42 	
       
    43 	if (ret!=KErrNone)
       
    44 		{
       
    45 		return ret;	
       
    46 		}
       
    47 	TRequestStatus stat;	
       
    48 	server.Rendezvous(stat);
       
    49 	server.Resume();
       
    50 	server.Close();
       
    51 	User::WaitForRequest(stat);
       
    52 	return stat.Int();		
       
    53 	}	
       
    54 	
       
    55 EXPORT_C TInt RCommsdatNotifier::Connect()
       
    56 	/** Connects to the server.
       
    57 	*
       
    58 	* 
       
    59 	* @return	KErrNone if successful; otherwise, a system-wide error code. */
       
    60 	{
       
    61 	TInt ret = CreateSession(COMMSDATNOTIFIER_SERVER_NAME,Version(),-1);
       
    62 
       
    63 	TInt outerLoopRetryCount = 0;
       
    64 	while ((ret == KErrNotFound) && (outerLoopRetryCount++ < KCommsDatServerMaxOuterLoopRetryCount))
       
    65 		{		
       
    66 		ret=StartNotifierProcess();
       
    67 		if (ret==KErrNone || ret==KErrAlreadyExists)
       
    68 			{
       
    69 			ret = CreateSession(COMMSDATNOTIFIER_SERVER_NAME,Version(),-1);
       
    70 			TInt innerLoopRetryCount = 0;
       
    71 			while ((ret == KErrNotFound) && (innerLoopRetryCount++ < KCommsDatServerMaxInnerLoopRetryCount))
       
    72 				{
       
    73 				User::After(KCommsDatServerRetryTimeout);
       
    74 				ret = CreateSession(COMMSDATNOTIFIER_SERVER_NAME,Version(),-1);				
       
    75 				}
       
    76 			
       
    77 			}
       
    78 			else
       
    79 			{
       
    80 				break; // we can't do anything more
       
    81 			}
       
    82 		}      	
       
    83 	return ret;
       
    84 	}
       
    85 
       
    86 
       
    87 EXPORT_C TVersion RCommsdatNotifier::Version() const
       
    88 	/** Gets the client side version number.
       
    89 	*
       
    90 	* @return	The client version number. */
       
    91 	{
       
    92 	return(TVersion(KCommsdatNotifierMajorVersionNumber,KCommsdatNotifierMinorVersionNumber,KCommsdatNotifierBuildVersionNumber));
       
    93 	}
       
    94 	
       
    95 	
       
    96 
       
    97 EXPORT_C void RCommsdatNotifier::RequestNotification(TRequestStatus& aStatus)
       
    98 	{
       
    99         SendReceive(ERequestNotify, TIpcArgs(),aStatus);
       
   100 	}
       
   101 	
       
   102 EXPORT_C void RCommsdatNotifier::CancelNotification()
       
   103 	{
       
   104 	SendReceive(ECancelNotify, TIpcArgs());
       
   105 	}	
       
   106 	
       
   107 EXPORT_C void RCommsdatNotifier::Close()
       
   108     {
       
   109 	RHandleBase::Close();
       
   110     }