diff -r f345bda72bc4 -r 43e37759235e Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/processclient_8cpp-source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/processclient_8cpp-source.html Tue Mar 30 11:56:28 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,124 +0,0 @@ - -
-00001 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -00002 // All rights reserved. -00003 // This component and the accompanying materials are made available -00004 // under the terms of "Eclipse Public License v1.0" -00005 // which accompanies this distribution, and is available -00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html". -00007 // -00008 // Initial Contributors: -00009 // Nokia Corporation - initial contribution. -00010 // -00011 // Contributors: -00012 // -00013 // Description: -00014 // -00015 -00016 -00017 #include "processclient.h" -00018 #include "processclientserver.h" -00019 #include<e32debug.h> -00020 -00021 #define KMaxServerNameLength 256 -00022 -00023 static const TUid KUidProcessServer = {0x10283037}; // Process Server UID -00024 const TInt KCreateSessionRetryCount = 2; //CreateSession retry count -00025 const TInt KServerDefaultMessageSlots = 2; //server async Message Slots -00026 -00033 static TInt StartServer() -00034 { -00035 const TUidType serverUid(KNullUid,KNullUid,KUidProcessServer); -00036 -00037 RProcess server; -00038 TInt r=server.Create(KProcessServerServerImg,KNullDesC,serverUid); -00039 if (r!=KErrNone) -00040 return r; -00041 TRequestStatus stat; -00042 server.Rendezvous(stat); -00043 -00044 if (stat!=KRequestPending) -00045 server.Kill(KErrCouldNotConnect); // abort startup -00046 else -00047 server.Resume(); // logon OK - start the server -00048 -00049 User::WaitForRequest(stat); // wait for start or death -00050 // The server exit type may be a panic value and a panic value can be zero, which is the same -00051 // value as KErrNone. So, the exit type is tested for a panic before being returned. -00052 if (server.ExitType()==EExitPanic) -00053 { -00054 r = KErrServerTerminated; -00055 } -00056 else -00057 { -00058 r = stat.Int(); -00059 } -00060 server.Close(); -00061 return r; -00062 } -00067 EXPORT_C TInt RProcessClient::Connect() -00068 { -00069 TInt retry=KCreateSessionRetryCount; //number of CreateSession retries -00070 FOREVER -00071 { -00072 // try to create a session with the server which has KServerDefaultMessageSlots async message slots. -00073 TInt r=CreateSession(KProcessServerName, -00074 TVersion(KProcessServerVersion, -00075 KProcessServerMinorVersionNumber, -00076 KProcessServerBuildVersionNumber), -00077 KServerDefaultMessageSlots); -00078 if (r!=KErrNotFound && r!=KErrServerTerminated) -00079 return r; -00080 if (--retry==0) -00081 return r; -00082 r=StartServer(); -00083 if (r!=KErrNone && r!=KErrAlreadyExists) -00084 return r; -00085 // 1. r=KErrNone means server starts up successfully. -00086 // 2. r=KErrAlreadyExists means a duplicate server was trying to start up. -00087 // Note: if there are other functions called before CServer2::StartL() during construction, -00088 // other errors might happen when the duplicate server is trying to start. -00089 // Therefore, we recommend CServer2::StartL() is the first function in server construction -00090 // @see CProcessServer::ConstructL() -00091 // -00092 // NOTE: If users would like to retry start up server after other scenarios happened, e.g. panic,then go -00093 // through the following steps: -00094 // 1. Increase the value of KCreateSessionRetryCount (only start up server once in this example) -00095 // 2. Need another variable, e.g. TExitType, together with error code returned in StartServer() -00096 // to distinguish these scenarios -00097 // 3. Modify the third if statement to stop exit when the required scenarios happens. -00098 // -00099 } -00100 } -00105 EXPORT_C TInt RProcessClient::OpenDriver() -00106 { -00107 return SendReceive(EOpenDriver); -00108 } -00114 EXPORT_C void RProcessClient::Send(const TDesC8& aBuf, TRequestStatus& aStatus) -00115 { -00116 SendReceive(EDummyLDDSendData, TIpcArgs(&aBuf), aStatus); -00117 } -00121 EXPORT_C void RProcessClient::SendCancel() -00122 { -00123 SendReceive(EDummyLDDSendDataCancel); -00124 } -00129 EXPORT_C TInt RProcessClient::UnloadDeviceDriver() -00130 { -00131 return SendReceive(EUnloadDeviceDriver); -00132 } -00137 EXPORT_C TInt RProcessClient::LoadDeviceDriver() -00138 { -00139 return SendReceive(ELoadDeviceDriver); -00140 } -00141 -00142 //EOF -