imsrv_plat/xmpp_settings_api/tsrc/src/xmppsettings_api.cpp
changeset 0 e6b17d312c8b
equal deleted inserted replaced
-1:000000000000 0:e6b17d312c8b
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 * 
       
    14 * Description: This file contains testclass implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <StifTestInterface.h>
       
    20 #include "xmppsettings_api.h"
       
    21 #include <SettingServerClient.h>
       
    22 #include<xmppservicesettingsapi.h>
       
    23 
       
    24 // EXTERNAL DATA STRUCTURES
       
    25 //extern  ?external_data;
       
    26 
       
    27 // EXTERNAL FUNCTION PROTOTYPES  
       
    28 //extern ?external_function( ?arg_type,?arg_type );
       
    29 
       
    30 // CONSTANTS
       
    31 //const ?type ?constant_var = ?constant;
       
    32 
       
    33 // MACROS
       
    34 //#define ?macro ?macro_def
       
    35 
       
    36 // LOCAL CONSTANTS AND MACROS
       
    37 //const ?type ?constant_var = ?constant;
       
    38 //#define ?macro_name ?macro_def
       
    39 
       
    40 // MODULE DATA STRUCTURES
       
    41 //enum ?declaration
       
    42 //typedef ?declaration
       
    43 
       
    44 // LOCAL FUNCTION PROTOTYPES
       
    45 //?type ?function_name( ?arg_type, ?arg_type );
       
    46 
       
    47 // FORWARD DECLARATIONS
       
    48 //class ?FORWARD_CLASSNAME;
       
    49 
       
    50 // ============================= LOCAL FUNCTIONS ===============================
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // ?function_name ?description.
       
    54 // ?description
       
    55 // Returns: ?value_1: ?description
       
    56 //          ?value_n: ?description_line1
       
    57 //                    ?description_line2
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 /*
       
    61 ?type ?function_name(
       
    62     ?arg_type arg,  // ?description
       
    63     ?arg_type arg)  // ?description
       
    64     {
       
    65 
       
    66     ?code  // ?comment
       
    67 
       
    68     // ?comment
       
    69     ?code
       
    70     }
       
    71 */
       
    72 
       
    73 // ============================ MEMBER FUNCTIONS ===============================
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // Cxmppsettings_api::Cxmppsettings_api
       
    77 // C++ default constructor can NOT contain any code, that
       
    78 // might leave.
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 Cxmppsettings_api::Cxmppsettings_api( 
       
    82     CTestModuleIf& aTestModuleIf ):
       
    83         CScriptBase( aTestModuleIf )
       
    84     {
       
    85     }
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // Cxmppsettings_api::ConstructL
       
    89 // Symbian 2nd phase constructor can leave.
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 void Cxmppsettings_api::ConstructL()
       
    93     {
       
    94         iXmppSettingId = 0;
       
    95         iXmppSnapId = 15;
       
    96         
       
    97         iXmppServerPort = 5223;
       
    98         iMessageToneVolume = 7;
       
    99         iLastRegistrationError = KErrNone;
       
   100 
       
   101         iPublishOnThePhoneStatus = ETrue;
       
   102         iRoamingWarning = ETrue;
       
   103         iAllowBuddyReq = ETrue;
       
   104         iAutoLogin = EFalse;
       
   105         iDefaultProfile = ETrue;
       
   106         
       
   107         iApi = CXmppSettingsApi::NewL();
       
   108          iMessageTone = HBufC::NewL( 50 );
       
   109         iMessageTone->Des().Copy( _L("c:\\system\\tones\\diipadaapa.wav") );
       
   110         
       
   111        // LOGARG16("messagetone path: %S", iMessageTone);
       
   112         
       
   113         iSnapName = HBufC::NewL( 50 );
       
   114         iSnapName->Des().Copy( _L("Internet") );
       
   115         
       
   116         iSettingsName = HBufC::NewL( 50 );
       
   117         iSettingsName->Des().Copy( _L("XMPP-SETTING 1") );
       
   118         
       
   119         iStackVersion = HBufC::NewL( 50 );
       
   120         iStackVersion->Des().Copy( _L("XMPP STACK V1.021 build 127") );
       
   121         
       
   122         iXmppServerAddress = HBufC::NewL( 50 );
       
   123         iXmppServerAddress->Des().Copy( _L("chat.gizmoproject.com") );
       
   124         
       
   125         iUsername = HBufC::NewL( 50 );
       
   126         iUsername->Des().Copy( _L("lassi") );
       
   127         
       
   128         iPassword = HBufC::NewL( 50 );
       
   129         iPassword->Des().Copy( _L("lassi123") );
       
   130         
       
   131         iConnectionServer1 = HBufC::NewL( 50 );
       
   132         iConnectionServer1->Des().Copy( _L("Con.Server.gizmo.com") );
       
   133         
       
   134         iConnectionServer2 = HBufC::NewL( 50 );
       
   135         iConnectionServer2->Des().Copy( _L("Con2.Server.gizmo.com") );
       
   136         
       
   137         
       
   138 
       
   139     //Read logger settings to check whether test case name is to be
       
   140     //appended to log file name.
       
   141     RSettingServer settingServer;
       
   142     TInt ret = settingServer.Connect();
       
   143     if(ret != KErrNone)
       
   144         {
       
   145         User::Leave(ret);
       
   146         }
       
   147     // Struct to StifLogger settigs.
       
   148     TLoggerSettings loggerSettings; 
       
   149     // Parse StifLogger defaults from STIF initialization file.
       
   150     ret = settingServer.GetLoggerSettings(loggerSettings);
       
   151     if(ret != KErrNone)
       
   152         {
       
   153         User::Leave(ret);
       
   154         } 
       
   155     // Close Setting server session
       
   156     settingServer.Close();
       
   157 
       
   158     TFileName logFileName;
       
   159     
       
   160     if(loggerSettings.iAddTestCaseTitle)
       
   161         {
       
   162         TName title;
       
   163         TestModuleIf().GetTestCaseTitleL(title);
       
   164         logFileName.Format(Kxmppsettings_apiLogFileWithTitle, &title);
       
   165         }
       
   166     else
       
   167         {
       
   168         logFileName.Copy(Kxmppsettings_apiLogFile);
       
   169         }
       
   170 
       
   171     iLog = CStifLogger::NewL( Kxmppsettings_apiLogPath, 
       
   172                           logFileName,
       
   173                           CStifLogger::ETxt,
       
   174                           CStifLogger::EFile,
       
   175                           EFalse );
       
   176     
       
   177     SendTestClassVersion();
       
   178     }
       
   179 
       
   180 // -----------------------------------------------------------------------------
       
   181 // Cxmppsettings_api::NewL
       
   182 // Two-phased constructor.
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 Cxmppsettings_api* Cxmppsettings_api::NewL( 
       
   186     CTestModuleIf& aTestModuleIf )
       
   187     {
       
   188     Cxmppsettings_api* self = new (ELeave) Cxmppsettings_api( aTestModuleIf );
       
   189 
       
   190     CleanupStack::PushL( self );
       
   191     self->ConstructL();
       
   192     CleanupStack::Pop();
       
   193 
       
   194     return self;
       
   195 
       
   196     }
       
   197 
       
   198 // Destructor
       
   199 Cxmppsettings_api::~Cxmppsettings_api()
       
   200     { 
       
   201 
       
   202     // Delete resources allocated from test methods
       
   203     Delete();
       
   204         delete iMessageTone;
       
   205         delete iSnapName;
       
   206         delete iSettingsName;
       
   207         delete iStackVersion;
       
   208         delete iXmppServerAddress;
       
   209         delete iUsername;
       
   210         delete iPassword;
       
   211         delete iConnectionServer1;
       
   212         delete iConnectionServer2;
       
   213         delete iApi;
       
   214     // Delete logger
       
   215     delete iLog; 
       
   216 
       
   217     }
       
   218 
       
   219 //-----------------------------------------------------------------------------
       
   220 // Cxmppsettings_api::SendTestClassVersion
       
   221 // Method used to send version of test class
       
   222 //-----------------------------------------------------------------------------
       
   223 //
       
   224 void Cxmppsettings_api::SendTestClassVersion()
       
   225 	{
       
   226 	TVersion moduleVersion;
       
   227 	moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
       
   228 	moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
       
   229 	moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
       
   230 	
       
   231 	TFileName moduleName;
       
   232 	moduleName = _L("xmppsettings_api.dll");
       
   233 
       
   234 	TBool newVersionOfMethod = ETrue;
       
   235 	TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
       
   236 	}
       
   237 
       
   238 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   239 
       
   240 // -----------------------------------------------------------------------------
       
   241 // LibEntryL is a polymorphic Dll entry point.
       
   242 // Returns: CScriptBase: New CScriptBase derived object
       
   243 // -----------------------------------------------------------------------------
       
   244 //
       
   245 EXPORT_C CScriptBase* LibEntryL( 
       
   246     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
       
   247     {
       
   248 
       
   249     return ( CScriptBase* ) Cxmppsettings_api::NewL( aTestModuleIf );
       
   250 
       
   251     }
       
   252 
       
   253 
       
   254 //  End of File