uiacceltk/hitchcock/plugins/openwfcrs/src/openwfcjob.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 // Copyright (c) 1995-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 "openwfcjob.h"
       
    17 #include "openwfcjobmanager.h"
       
    18 
       
    19 TOpenWfcJob::TOpenWfcJob(COpenWfcJobManger& aJobManager):
       
    20 iJobManager(aJobManager),
       
    21 iJobId(EInvalidJobId), 
       
    22 iCallingThread(KNullThreadId),
       
    23 iCompleteRequest(NULL)
       
    24 	{
       
    25 	
       
    26 	}
       
    27 
       
    28 void TOpenWfcJob::Set(EOpenWfcJobId aJob,
       
    29 		              TThreadId aThreadId,
       
    30 		              TRequestStatus* aRequest)
       
    31 	{
       
    32 	iJobId = aJob; 
       
    33 	iCallingThread = aThreadId;
       
    34 	iCompleteRequest =aRequest;
       
    35     JQLOG(("** TOpenWfcJob::Sett() : iCompleteRequest(0x%x) iJobId(%d)", aRequest, aJob));
       
    36 	}
       
    37 
       
    38 
       
    39 void TOpenWfcJob::Reset()
       
    40 	{
       
    41 	iJobId = EInvalidJobId; 
       
    42 	iCallingThread = KNullThreadId;
       
    43 	iCompleteRequest =NULL;
       
    44 	}
       
    45 
       
    46 TOpenWfcJob::~TOpenWfcJob()
       
    47 	{
       
    48 	}
       
    49 
       
    50 
       
    51 void TOpenWfcJob::Run()
       
    52 	{
       
    53 	switch (iJobId)
       
    54 		{
       
    55 		case EComposeJobId:
       
    56             JQLOG(("** LAUNCH * TOpenWfcJob::Run EComposeJobId"));
       
    57 			iJobManager.DoComposeJob(*this);
       
    58 			break;
       
    59 		case EPauseCompositionJobId:
       
    60             JQLOG(("** LAUNCH * TOpenWfcJob::Run EPauseCompositionJobId"));
       
    61 			iJobManager.DoPauseCompositionJob(*this);
       
    62 			break;
       
    63 		case EResumeCompositionJobId:
       
    64             JQLOG(("** LAUNCH * TOpenWfcJob::Run EResumeCompositionJobId"));
       
    65 			iJobManager.DoResumeCompositionJob(*this);
       
    66 			break;
       
    67 		default:
       
    68 		    JQLOG(("** ERROR * TOpenWfcJob::Run jobId(%d)", iJobId));
       
    69 			break;
       
    70 		}
       
    71 	}
       
    72 
       
    73 void TOpenWfcJob::CompleteRequest(TInt aResult)
       
    74     {
       
    75     if (iCompleteRequest)
       
    76         {
       
    77         RThread thread;
       
    78         
       
    79         if (thread.Open(iCallingThread) == KErrNone)
       
    80             {
       
    81             JQLOG(("** TOpenWfcJob::CompleteRequest(): CompleteReq(0x%x))", iCompleteRequest));
       
    82             thread.RequestComplete(iCompleteRequest, aResult);
       
    83             thread.Close();
       
    84             }
       
    85         }
       
    86     }