localconnectivityservice/obexsendservices/obexhighway/src/btsssendlisthandler.cpp
changeset 24 c55c8fddf124
parent 21 23264c07fd05
equal deleted inserted replaced
21:23264c07fd05 24:c55c8fddf124
     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:  Converter class implementation for converting AIW paramerer 
       
    15 *                list to bt send parameter list
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <AiwGenericParam.h>
       
    21 
       
    22 #include "btsssendlisthandler.h"
       
    23 #include "BTServiceParameterList.h"
       
    24 
       
    25 #include <xqconversions.h>
       
    26 
       
    27 // ======== MEMBER FUNCTIONS ========
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // CBTSSSendListHandler()
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 CBTSSSendListHandler::CBTSSSendListHandler(): CActive( EPriorityNormal )
       
    34     {
       
    35     CActiveScheduler::Add(this);
       
    36     }
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // ConstructL()
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 void CBTSSSendListHandler::ConstructL()
       
    43     {
       
    44     }
       
    45 
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // NewL()
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 CBTSSSendListHandler* CBTSSSendListHandler::NewL()
       
    52     {
       
    53     CBTSSSendListHandler* self = CBTSSSendListHandler::NewLC();
       
    54     CleanupStack::Pop( self );
       
    55     return self;
       
    56     }
       
    57 
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // NewLC()
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 CBTSSSendListHandler* CBTSSSendListHandler::NewLC()
       
    64     {
       
    65     CBTSSSendListHandler* self = new( ELeave ) CBTSSSendListHandler();
       
    66     CleanupStack::PushL( self );
       
    67     self->ConstructL();
       
    68     return self;
       
    69     }
       
    70 
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // CBTSSSendListHandler
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 CBTSSSendListHandler::~CBTSSSendListHandler()    
       
    77     {
       
    78     FLOG(_L("[BTSS]\t CBTSSSendListHandler::Destructor"));     
       
    79     Cancel();
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // ConvertList()
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 TInt CBTSSSendListHandler::ConvertList( const QList<QVariant> *arguments, 
       
    87                                         CBTServiceParameterList* aList)
       
    88     {
       
    89     FLOG(_L("[BTSS]\t CBTSSSendListHandler::ConvertList"));           
       
    90     iListIndex = 0;    
       
    91     mArguments = arguments;
       
    92     iList = aList;
       
    93     iStatus = KRequestPending;
       
    94     AddObject();
       
    95     SetActive();
       
    96     
       
    97     iSyncWaiter.Start();
       
    98     FLOG(_L("[BTSS]\t CBTSSSendListHandler::ConvertList done"));           
       
    99     return iStatus.Int();
       
   100     }
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // AddObject()
       
   104 // ---------------------------------------------------------------------------
       
   105 //
       
   106 void CBTSSSendListHandler::AddObject()
       
   107     {
       
   108     FLOG(_L("[BTSS]\t CBTSSSendListHandler::AddObjectL()"));       
       
   109     TRAPD(error, DoAddObjectL());
       
   110     if (error != KErrNone )
       
   111         {        
       
   112         //Complete request
       
   113         TRequestStatus* status = &iStatus;
       
   114         User::RequestComplete(status, error);
       
   115         }
       
   116     FLOG(_L("[BTSS]\t CBTSSSendListHandler::AddObjectL() Done"));           
       
   117     }
       
   118 
       
   119 // ---------------------------------------------------------------------------
       
   120 // From class CActive.
       
   121 // RunL()
       
   122 // ---------------------------------------------------------------------------
       
   123 //
       
   124 void CBTSSSendListHandler::DoAddObjectL()
       
   125     {
       
   126     FLOG(_L("[BTSS]\t CBTSSSendListHandler::DoAddObjectL()"));   
       
   127     
       
   128  //   const TAiwGenericParam* param=&(*iOutParamList)[iListIndex];
       
   129     
       
   130     QString string = mArguments->at(iListIndex).toString();
       
   131 
       
   132  /*   if ( param->SemanticId() != EGenericParamFile )
       
   133         {
       
   134         FLOG(_L("[BTSS]\t CBTSSSendListHandler::DoAddObjectL() wrong semantic Id: Leave"));            
       
   135         }
       
   136       // Try to add file as an image
       
   137       //       
       
   138     if( param->Value().TypeId()== EVariantTypeFileHandle)
       
   139         {           
       
   140         TRAPD( retVal, iList->AddImageL( param->Value().AsFileHandle()  ));
       
   141         FLOG(_L("[BTSS]\t CBTSSSendListHandler::DoAddObjectL AddImage"));            
       
   142         if( retVal != KErrNone )
       
   143             {
       
   144             // File was not an image. We can not use BIP 
       
   145             // so add rest of the files as objects
       
   146             //             
       
   147             FLOG(_L("[BTSS]\t CBTSSSendListHandler::DoAddObjectL AddImage filed try object"));            
       
   148             iList->AddObjectL( param->Value().AsFileHandle() );
       
   149             }            
       
   150         }
       
   151     else */
       
   152  //       {           
       
   153        // TRAPD( retVal, iList->AddImageL( param->Value().AsDes() ) );
       
   154         HBufC* path = XQConversions::qStringToS60Desc(string);
       
   155         TRAPD( retVal, iList->AddImageL(*path));
       
   156         if( retVal != KErrNone )
       
   157             {
       
   158             // File was not an image. We can not use BIP 
       
   159             // so add rest of the files as objects
       
   160             //                
       
   161             iList->AddObjectL( *path );
       
   162             }
       
   163   //      }
       
   164       //Complete request
       
   165     TRequestStatus* status = &iStatus;
       
   166     User::RequestComplete(status, KErrNone);
       
   167       
       
   168     FLOG(_L("[BTSS]\t CBTSSSendListHandler::DoAddObjectL() completed"));  
       
   169     }
       
   170 // ---------------------------------------------------------------------------
       
   171 // From class CActive.
       
   172 // RunL()
       
   173 // ---------------------------------------------------------------------------
       
   174 //
       
   175 void CBTSSSendListHandler::RunL()
       
   176     {
       
   177     FLOG(_L("[BTSS]\t CBTSSSendListHandler::DoAddObjectL()"));       
       
   178     iListIndex++;
       
   179     if ( mArguments->count() > iListIndex && iStatus.Int() == KErrNone )
       
   180         {        
       
   181         iStatus = KRequestPending;
       
   182         AddObject();
       
   183         SetActive();
       
   184         }
       
   185     else
       
   186         {
       
   187         if ( iSyncWaiter.IsStarted() )
       
   188             {
       
   189             iSyncWaiter.AsyncStop();
       
   190             }
       
   191         }
       
   192     FLOG(_L("[BTSS]\t CBTSSSendListHandler::DoAddObjectL() Done"));           
       
   193     }