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