mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsscriptsender.cpp
changeset 47 63cf70d3ecd8
parent 28 85e0c0339cc3
equal deleted inserted replaced
44:a5deb6b96675 47:63cf70d3ecd8
    14 * Description:  This class implements the dps script sending function. 
    14 * Description:  This class implements the dps script sending function. 
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include <e32debug.h>
       
    20 #include <f32file.h>
    19 #include <f32file.h>
    21 #include "dpsscriptsender.h"
    20 #include "dpsscriptsender.h"
    22 #include "dpsstatemachine.h"
    21 #include "dpsstatemachine.h"
    23 #include "pictbridge.h"
    22 #include "pictbridge.h"
    24 #include "dpstransaction.h"
    23 #include "dpstransaction.h"
    25 #include "dpsfile.h"
    24 #include "dpsfile.h"
    26 
    25 #include "OstTraceDefinitions.h"
    27 #ifdef _DEBUG
    26 #ifdef OST_TRACE_COMPILER_IN_USE
    28 #	define IF_DEBUG(t) {RDebug::t;}
    27 #include "dpsscriptsenderTraces.h"
    29 #else
       
    30 #	define IF_DEBUG(t)
       
    31 #endif
    28 #endif
    32 
    29 
    33 // ---------------------------------------------------------------------------
    30 // ---------------------------------------------------------------------------
    34 // 
    31 // 
    35 // ---------------------------------------------------------------------------
    32 // ---------------------------------------------------------------------------
    36 //
    33 //
    37 CDpsScriptSender* CDpsScriptSender::NewL(CDpsStateMachine* aOperator)
    34 CDpsScriptSender* CDpsScriptSender::NewL(CDpsStateMachine* aOperator)
    38     {
    35     {
    39     IF_DEBUG(Print(_L("CDpsScriptSender::NewL")));
       
    40     CDpsScriptSender* self = new(ELeave) CDpsScriptSender(aOperator);
    36     CDpsScriptSender* self = new(ELeave) CDpsScriptSender(aOperator);
    41     return self;	
    37     return self;	
    42     }
    38     }
    43 
    39 
    44 // ---------------------------------------------------------------------------
    40 // ---------------------------------------------------------------------------
    47 //
    43 //
    48 CDpsScriptSender::CDpsScriptSender(CDpsStateMachine* aOperator) : 
    44 CDpsScriptSender::CDpsScriptSender(CDpsStateMachine* aOperator) : 
    49     CActive(EPriorityNormal), iOperator(aOperator), 
    45     CActive(EPriorityNormal), iOperator(aOperator), 
    50     iReply(EFalse) 
    46     iReply(EFalse) 
    51     {
    47     {
    52     IF_DEBUG(Print(_L(">>>CDpsScriptSender::Ctor")));
    48     OstTraceFunctionEntry0( CDPSSCRIPTSENDER_CDPSSCRIPTSENDER_CONS_ENTRY );
    53     CActiveScheduler::Add(this);  
    49     CActiveScheduler::Add(this);  
    54     IF_DEBUG(Print(_L("<<<CDpsScriptSender::Ctor")));
    50     OstTraceFunctionExit0( CDPSSCRIPTSENDER_CDPSSCRIPTSENDER_CONS_EXIT );
    55     }  
    51     }  
    56   
    52   
    57 // ---------------------------------------------------------------------------
    53 // ---------------------------------------------------------------------------
    58 // 
    54 // 
    59 // ---------------------------------------------------------------------------
    55 // ---------------------------------------------------------------------------
    60 //	
    56 //	
    61 CDpsScriptSender::~CDpsScriptSender()
    57 CDpsScriptSender::~CDpsScriptSender()
    62     {
    58     {
    63     IF_DEBUG(Print(_L(">>>~CDpsScriptSender")));
    59     OstTraceFunctionEntry0( DUP1_CDPSSCRIPTSENDER_CDPSSCRIPTSENDER_DES_ENTRY );
    64     Cancel();
    60     Cancel();
    65     IF_DEBUG(Print(_L("<<<~CDpsScriptSender")));	
    61     OstTraceFunctionExit0( DUP1_CDPSSCRIPTSENDER_CDPSSCRIPTSENDER_DES_EXIT );
    66     }
    62     }
    67  
    63  
    68 // ---------------------------------------------------------------------------
    64 // ---------------------------------------------------------------------------
    69 // 
    65 // 
    70 // ---------------------------------------------------------------------------
    66 // ---------------------------------------------------------------------------
    71 //  
    67 //  
    72 TInt CDpsScriptSender::SendScript(TBool aReply)
    68 TInt CDpsScriptSender::SendScript(TBool aReply)
    73     {
    69     {
    74     IF_DEBUG(Print(_L(">>>CDpsScriptSender::SendScript")));  
    70     OstTraceFunctionEntry0( CDPSSCRIPTSENDER_SENDSCRIPT_ENTRY ); 
    75     if (!IsActive())
    71     if (!IsActive())
    76         {
    72         {
    77         iReply = aReply;  
    73         iReply = aReply;  
    78         TFileName file(iOperator->DpsEngine()->DpsFolder());
    74         TFileName file(iOperator->DpsEngine()->DpsFolder());
    79         RFile script;
    75         RFile script;
    87             }
    83             }
    88         TInt err = script.Open(iOperator->Trader()->
    84         TInt err = script.Open(iOperator->Trader()->
    89             FileHandle()->FileSession(), file, EFileRead);
    85             FileHandle()->FileSession(), file, EFileRead);
    90         if (err != KErrNone)
    86         if (err != KErrNone)
    91             {
    87             {
       
    88             OstTraceFunctionExit0( CDPSSCRIPTSENDER_SENDSCRIPT_EXIT );
    92             return err;
    89             return err;
    93             }
    90             }
    94         TInt size;    
    91         TInt size;    
    95         script.Size(size);
    92         script.Size(size);
    96         script.Close();
    93         script.Close();
   103             {            
   100             {            
   104             iOperator->DpsEngine()->
   101             iOperator->DpsEngine()->
   105                 Ptp().SendObject(file, iStatus, ETrue, size);
   102                 Ptp().SendObject(file, iStatus, ETrue, size);
   106             }
   103             }
   107         SetActive();    
   104         SetActive();    
   108         IF_DEBUG(Print(_L("<<<CDpsScriptSender::SendScript")));
   105 	    OstTraceFunctionExit0( DUP1_CDPSSCRIPTSENDER_SENDSCRIPT_EXIT );
   109 	    return KErrNone;
   106 	    return KErrNone;
   110         }
   107         }
   111     else
   108     else
   112         {
   109         {
       
   110         OstTraceFunctionExit0( DUP2_CDPSSCRIPTSENDER_SENDSCRIPT_EXIT );
   113         return KErrInUse;
   111         return KErrInUse;
   114         }
   112         }
   115     }
   113     }
   116  
   114  
   117 // ---------------------------------------------------------------------------
   115 // ---------------------------------------------------------------------------
   118 // 
   116 // 
   119 // ---------------------------------------------------------------------------
   117 // ---------------------------------------------------------------------------
   120 //
   118 //
   121 void CDpsScriptSender::RunL()
   119 void CDpsScriptSender::RunL()
   122     {
   120     {
   123     IF_DEBUG(Print(_L(">>>CDpsScriptSender::RunL")));
   121     OstTraceFunctionEntry0( CDPSSCRIPTSENDER_RUNL_ENTRY );
   124     
   122     
   125     if (KErrNone == iStatus.Int())
   123     if (KErrNone == iStatus.Int())
   126         {
   124         {
   127         // the device request is sent
   125         // the device request is sent
   128         if (!iReply)
   126         if (!iReply)
   135             iOperator->ScriptSentNotifyL(ETrue);      
   133             iOperator->ScriptSentNotifyL(ETrue);      
   136             }
   134             }
   137         }                
   135         }                
   138     else
   136     else
   139     	{
   137     	{
   140         IF_DEBUG(Print(_L("the iStatus is wrong %d!!!"), iStatus.Int()));
   138         OstTrace1( TRACE_ERROR, CDPSSCRIPTSENDER_RUNL, "the iStatus is wrong %d!!!", iStatus.Int() );
   141         iOperator->Error(iStatus.Int());
   139         iOperator->Error(iStatus.Int());
   142     	}
   140     	}
   143     IF_DEBUG(Print(_L("<<<CDpsScriptSender::RunL")));
   141     OstTraceFunctionExit0( CDPSSCRIPTSENDER_RUNL_EXIT );
   144     }
   142     }
   145   
   143   
   146 // ---------------------------------------------------------------------------
   144 // ---------------------------------------------------------------------------
   147 // 
   145 // 
   148 // ---------------------------------------------------------------------------
   146 // ---------------------------------------------------------------------------
   149 //  
   147 //  
   150 void CDpsScriptSender::DoCancel()
   148 void CDpsScriptSender::DoCancel()
   151     {
   149     {
   152     IF_DEBUG(Print(_L(">>>CDpsScriptSender::DoCancel")));
   150     OstTraceFunctionEntry0( CDPSSCRIPTSENDER_DOCANCEL_ENTRY );
   153     iOperator->DpsEngine()->Ptp().CancelSendObject();
   151     iOperator->DpsEngine()->Ptp().CancelSendObject();
   154     IF_DEBUG(Print(_L("<<<CDpsScriptSender::DoCancel")));
   152     OstTraceFunctionExit0( CDPSSCRIPTSENDER_DOCANCEL_EXIT );
   155     }
   153     }
   156 
   154 
   157 // ---------------------------------------------------------------------------
   155 // ---------------------------------------------------------------------------
   158 // 
   156 // 
   159 // ---------------------------------------------------------------------------
   157 // ---------------------------------------------------------------------------
   160 //	
   158 //	
   161 TInt CDpsScriptSender::RunError(TInt aError)	
   159 TInt CDpsScriptSender::RunError(TInt aError)	
   162     {
   160     {
   163     IF_DEBUG(Print(_L(">>>CDpsScriptSender::RunError is %d"), aError));
   161     OstTraceFunctionEntry0( CDPSSCRIPTSENDER_RUNERROR_ENTRY );
       
   162     OstTraceDef1( OST_TRACE_CATEGORY_PRODUCTION, TRACE_IMPORTANT, CDPSSCRIPTSENDER_RUNERROR, 
       
   163             "error code %d", aError);
   164     Cancel();
   164     Cancel();
   165     iOperator->Error(aError);
   165     iOperator->Error(aError);
   166     IF_DEBUG(Print(_L("<<<CDpsScriptSender::RunError")));
   166     OstTraceFunctionExit0( CDPSSCRIPTSENDER_RUNERROR_EXIT );
   167     return KErrNone;
   167     return KErrNone;
   168     }
   168     }