realtimenetprots/sipfw/ProfileAgent/Client/Src/SIPRemoteProfile.cpp
changeset 0 307788aac0a8
child 6 43c4dec3cb1f
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 // Copyright (c) 2003-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 // Name        : sipremoteprofile
       
    15 // Part of     : SIP Profile Client
       
    16 // implementation
       
    17 // Version     : 1.0
       
    18 // INCLUDE FILES
       
    19 //
       
    20 
       
    21 
       
    22 
       
    23 #include "SIPRemoteProfile.h"
       
    24 #include "sipprofilecs.h"
       
    25 #include "SIPProfileServerStarter.h"
       
    26 #include "sipprofileclient.pan"
       
    27 
       
    28 
       
    29 // ============================ MEMBER FUNCTIONS ===============================
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 // RSIPProfile::RSIPProfile
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 RSIPProfile::RSIPProfile()
       
    36  : RSessionBase (), iConnected (EFalse)
       
    37 	{
       
    38 	}
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // RSIPProfile::Version
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 TVersion RSIPProfile::Version(void) const
       
    45 	{
       
    46     TVersion version (KSipProfileServerMajorVersionNumber,
       
    47                       KSipProfileServerMinorVersionNumber,
       
    48                       KSipProfileServerBuildVersionNumber);
       
    49     return version;
       
    50 	}
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // RSIPProfile::Connect
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 TInt RSIPProfile::Connect()
       
    57 	{
       
    58 	TBool stopTrying(EFalse);
       
    59     TInt err(KErrNone);
       
    60     const TInt KMaxRetries(10);
       
    61     TInt retryCount(0);
       
    62     
       
    63     while (!stopTrying && retryCount < KMaxRetries)
       
    64         {
       
    65         err = CreateSession(KSipProfileServerName,Version());
       
    66         if ((err != KErrNotFound) && (err != KErrServerTerminated))
       
    67             {
       
    68             stopTrying = ETrue;
       
    69             }
       
    70         else
       
    71             {
       
    72             err = TSIPProfileServerStarter::Start();
       
    73             if ((err != KErrNone) && (err != KErrAlreadyExists))
       
    74                 {
       
    75                 stopTrying = ETrue;
       
    76                 }
       
    77             }
       
    78         retryCount++;
       
    79 	    }
       
    80 	    
       
    81     iConnected = (err == KErrNone);
       
    82     return err;
       
    83 	}
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // RSIPProfile::Close
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 void RSIPProfile::Close()
       
    90 	{
       
    91     iConnected = EFalse;
       
    92     RHandleBase::Close();
       
    93 	}
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // RSIPProfile::Send
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 TInt RSIPProfile::Send(TIpcArgs& aArgs, TSipProfileItcFunctions aFunction)
       
   100 	{
       
   101 	__ASSERT_ALWAYS (iConnected, Panic(ESipClientNotConnected));
       
   102 
       
   103     return SendReceive (aFunction, aArgs);
       
   104 	}
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // RSIPProfile::Receive
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 void RSIPProfile::Receive(TIpcArgs& aArgs, TRequestStatus& aStatus)
       
   111 
       
   112 	{
       
   113 	__ASSERT_ALWAYS (iConnected, Panic(ESipClientNotConnected));
       
   114 
       
   115     SendReceive(ESipProfileItcOpReadyToReceive,aArgs,aStatus);
       
   116 	}
       
   117 
       
   118 // -----------------------------------------------------------------------------
       
   119 // RSIPProfile::CancelReceive
       
   120 // -----------------------------------------------------------------------------
       
   121 //
       
   122 void RSIPProfile::CancelReceive()
       
   123 	{
       
   124     __ASSERT_ALWAYS (iConnected, Panic(ESipClientNotConnected));
       
   125 
       
   126     SendReceive (ESipProfileItcOpCancelReceive, TIpcArgs());
       
   127 	}
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // RSIPProfile::Panic
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 void RSIPProfile::Panic(TInt aReason)
       
   134 	{
       
   135     User::Panic(KSipProfileClient, aReason);
       
   136 	}