00001 // Copyright (c) 2000-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 // ComplexServer.cpp 00015 // 00016 00017 #include "ComplexClientAndServer.h" 00018 #include "ComplexServer.h" 00019 #include <e32svr.h> 00020 #include <e32uid.h> 00021 00022 00023 00024 00025 //********************************** 00026 //CCountSubSession implementation 00027 //********************************** 00028 00029 // construction 00030 CCountSubSession::CCountSubSession(CCountSession* aSession) 00031 : iSession(aSession) 00032 { 00033 } 00034 00035 00041 void CCountSubSession::SetFromStringL(const RMessage2& aMessage) 00042 { 00043 // length of passed descriptor (1st parameter passed from client) 00044 TInt deslen = aMessage.GetDesLength(0); 00045 00046 // Passed data will be saved in this descriptor. 00047 RBuf buffer; 00048 00049 // Max length set to the value of "deslen", but current length is zero 00050 buffer.CreateL(deslen); 00051 00052 // Do the right cleanup if anything subsequently goes wrong 00053 buffer.CleanupClosePushL(); 00054 00055 // Copy the client's descriptor data into our buffer. 00056 aMessage.ReadL(0,buffer,0); 00057 00058 // Now do a validation to make sure that the string only has digits 00059 if (buffer.Length() == 0) 00060 { 00061 User::Leave(ENonNumericString); 00062 } 00063 00064 TLex16 lexer; 00065 00066 lexer.Assign(buffer); 00067 while (!lexer.Eos()) 00068 { 00069 TChar thechar; 00070 00071 thechar = lexer.Peek(); 00072 if (!thechar.IsDigit()) 00073 { 00074 User::Leave(ENonNumericString); 00075 } 00076 lexer.Inc(); 00077 } 00078 00079 // Convert to a simple TInt value. 00080 lexer.Assign(buffer); 00081 if (lexer.Val(iCount)) 00082 { 00083 User::Leave(ENonNumericString); 00084 } 00085 00086 // Clean up the memory acquired by the RBuf variable "buffer" 00087 CleanupStack::PopAndDestroy(); 00088 } 00089 00090 00094 void CCountSubSession::Increase() 00095 { 00096 iCount++; 00097 } 00098 00099 00103 void CCountSubSession::IncreaseBy(const RMessage2& aMessage) 00104 { 00105 iCount+=aMessage.Int0(); 00106 } 00107 00108 00112 void CCountSubSession::Decrease() 00113 { 00114 iCount--; 00115 } 00116 00117 00121 void CCountSubSession::DecreaseBy(const RMessage2& aMessage) 00122 { 00123 iCount-=aMessage.Int0(); 00124 } 00125 00126 00130 void CCountSubSession::Reset() 00131 { 00132 iCount=0; 00133 } 00134 00135 00140 void CCountSubSession::CounterValueL(const RMessage2& aMessage) 00141 { 00142 TPckgBuf<TInt> p(iCount); 00143 aMessage.WriteL(0,p); 00144 } 00145 00146
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.