tzservices/tzserver/test/switest/src/ctzswiplugintester.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 2008-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 #include "ctzswiplugintester.h"
       
    17 #include "cswiappinstall.h"
       
    18 #include "testserver.h"
       
    19 #include <tzupdate.h>
       
    20 
       
    21 CCTzSwiPluginTester::CCTzSwiPluginTester() :
       
    22 	CActive(EPriorityStandard)
       
    23 	{
       
    24 	CActiveScheduler::Add(this);
       
    25 	}
       
    26 
       
    27 EXPORT_C CCTzSwiPluginTester* CCTzSwiPluginTester::NewLC()
       
    28 	{
       
    29 	CCTzSwiPluginTester* self = new ( ELeave ) CCTzSwiPluginTester();
       
    30 	CleanupStack::PushL(self);
       
    31 	self->ConstructL();
       
    32 	return self;
       
    33 	}
       
    34 
       
    35 EXPORT_C CCTzSwiPluginTester* CCTzSwiPluginTester::NewL()
       
    36 	{
       
    37 	CCTzSwiPluginTester* self = CCTzSwiPluginTester::NewLC();
       
    38 	CleanupStack::Pop(); // self;
       
    39 	return self;
       
    40 	}
       
    41 
       
    42 void CCTzSwiPluginTester::ConstructL()
       
    43 	{
       
    44 	User::LeaveIfError(iFs.Connect());
       
    45 	//Add the log file, this enables us to figure out when the sis install is complete
       
    46 	iFs.MkDirAll(KSwiTzLogDir());
       
    47 	iFs.Delete(KSwiTzLogFile());
       
    48 	User::LeaveIfError(iPropertyDb.Attach(NTzUpdate::KPropertyCategory, NTzUpdate::ETzRulesChange));
       
    49 	User::LeaveIfError(iPropertyLoc.Attach(NTzUpdate::KPropertyCategory, NTzUpdate::ETzNamesChange));
       
    50 	}
       
    51 
       
    52 EXPORT_C CCTzSwiPluginTester::~CCTzSwiPluginTester()
       
    53 	{
       
    54 	Cancel();
       
    55 	iFs.Close();
       
    56 	iPropertyDb.Close();
       
    57 	iPropertyLoc.Close();
       
    58 	}
       
    59 
       
    60 void CCTzSwiPluginTester::DoCancel()
       
    61 	{
       
    62 	switch (iNotifyType)
       
    63 		{
       
    64 		case EPropertyRules:
       
    65 			iPropertyDb.Cancel();
       
    66 			break;
       
    67 		case EPropertyNames:
       
    68 			iPropertyLoc.Cancel();
       
    69 			break;
       
    70 		case EFileLog:
       
    71 			iFs.NotifyChangeCancel(*iReqStatus);
       
    72 			break;
       
    73 		}
       
    74 	}
       
    75 
       
    76 void CCTzSwiPluginTester::RunL()
       
    77 	{
       
    78 //	Cancel(); //Check that this does not cause any problems!!
       
    79 	User::RequestComplete(iReqStatus, KErrNone);
       
    80 	CActiveScheduler::Stop();
       
    81 	}
       
    82 
       
    83 TInt CCTzSwiPluginTester::RunError(TInt aError)
       
    84 	{
       
    85 	Cancel();
       
    86 	User::RequestComplete(iReqStatus, aError);
       
    87 	CActiveScheduler::Stop();
       
    88 	return aError;
       
    89 	}
       
    90 
       
    91 EXPORT_C void CCTzSwiPluginTester::InstallSIS(const TDesC& aSisFile, TUint aNotifyType, TRequestStatus& aReqStatus)
       
    92 	{
       
    93 	iNotifyType = static_cast<CCTzSwiPluginTester::TNotifyType> (aNotifyType);
       
    94 	switch (iNotifyType)
       
    95 		{
       
    96 		case EPropertyRules:
       
    97 			{
       
    98 			if (!IsActive())
       
    99 				{
       
   100 				aReqStatus = KRequestPending;
       
   101 				iReqStatus = &aReqStatus;
       
   102 				iPropertyDb.Subscribe(iStatus);
       
   103 				SetActive();
       
   104 				}
       
   105 			}
       
   106 			break;
       
   107 		case EPropertyNames:
       
   108 			{
       
   109 			if (!IsActive())
       
   110 				{
       
   111 				aReqStatus = KRequestPending;
       
   112 				iReqStatus = &aReqStatus;
       
   113 				iPropertyLoc.Subscribe(iStatus);
       
   114 				SetActive();
       
   115 				}
       
   116 			}
       
   117 			break;
       
   118 		case EFileLog:
       
   119 			{
       
   120 			if (!IsActive())
       
   121 				{
       
   122 				aReqStatus = KRequestPending;
       
   123 				iReqStatus = &aReqStatus;
       
   124 				iFs.NotifyChange(ENotifyAll, iStatus, KSwiTzLogDir());
       
   125 				SetActive();
       
   126 				}
       
   127 			}
       
   128 			break;
       
   129 		}
       
   130 	TRAPD(err, CSwiAppInstall::InstallL(aSisFile));
       
   131 	if (err != KErrNone)
       
   132 		{
       
   133 		Cancel();
       
   134 		}
       
   135 	}
       
   136 
       
   137 EXPORT_C void CCTzSwiPluginTester::UninstallSIS(const TDesC& aApplicationUID, const TDesC& aPackageName, const TDesC& aVendorId, TUint aNotifyType, TRequestStatus& aReqStatus)
       
   138 	{
       
   139 	iNotifyType = static_cast<CCTzSwiPluginTester::TNotifyType> (aNotifyType);
       
   140 	switch (iNotifyType)
       
   141 		{
       
   142 		case EPropertyRules:
       
   143 			{
       
   144 			if (!IsActive())
       
   145 				{
       
   146 				aReqStatus = KRequestPending;
       
   147 				iReqStatus = &aReqStatus;
       
   148 				iPropertyDb.Subscribe(iStatus);
       
   149 				SetActive();
       
   150 				}
       
   151 			}
       
   152 			break;
       
   153 		case EPropertyNames:
       
   154 			{
       
   155 			if (!IsActive())
       
   156 				{
       
   157 				aReqStatus = KRequestPending;
       
   158 				iReqStatus = &aReqStatus;
       
   159 				iPropertyLoc.Subscribe(iStatus);
       
   160 				SetActive();
       
   161 				}
       
   162 			}
       
   163 			break;
       
   164 		case EFileLog:
       
   165 			{
       
   166 			if (!IsActive())
       
   167 				{
       
   168 				aReqStatus = KRequestPending;
       
   169 				iReqStatus = &aReqStatus;
       
   170 				iFs.NotifyChange(ENotifyAll, iStatus, KSwiTzLogDir());
       
   171 				SetActive();
       
   172 				}
       
   173 			}
       
   174 			break;
       
   175 		}
       
   176 	TRAPD(err, CSwiAppInstall::UninstallL(aApplicationUID, aPackageName, aVendorId));
       
   177 	if (err != KErrNone)
       
   178 		{
       
   179 		Cancel();
       
   180 		}
       
   181 	}
       
   182 
       
   183 EXPORT_C TInt CCTzSwiPluginTester::UninstallSIS(const TDesC& aApplicationUID, const TDesC& aPackageName, const TDesC& aVendorId)
       
   184 	{
       
   185 	TRAPD(err, CSwiAppInstall::UninstallL(aApplicationUID, aPackageName, aVendorId));
       
   186 	return err;
       
   187 	}
       
   188 
       
   189 EXPORT_C TInt CCTzSwiPluginTester::InstallSIS(const TDesC& aSisFile)
       
   190 	{
       
   191 	TRAPD(err,CSwiAppInstall::InstallL(aSisFile));
       
   192 	return err;
       
   193 	}