mtpdataproviders/mtppictbridgedp/src/cptpsession.cpp
changeset 47 63cf70d3ecd8
parent 0 d0791faffa3f
equal deleted inserted replaced
44:a5deb6b96675 47:63cf70d3ecd8
    20 #include "cptpserver.h"
    20 #include "cptpserver.h"
    21 #include "cptpreceivedmsghandler.h"
    21 #include "cptpreceivedmsghandler.h"
    22 #include "cmtppictbridgeprinter.h"
    22 #include "cmtppictbridgeprinter.h"
    23 #include "cptptimer.h"
    23 #include "cptptimer.h"
    24 #include "mtppictbridgedpconst.h"
    24 #include "mtppictbridgedpconst.h"
    25 #include "ptpdef.h" 
    25 #include "ptpdef.h"
       
    26 #include "mtpdebug.h"
       
    27 #include "OstTraceDefinitions.h"
       
    28 #ifdef OST_TRACE_COMPILER_IN_USE
       
    29 #include "cptpsessionTraces.h"
       
    30 #endif
       
    31  
    26 
    32 
    27 // --------------------------------------------------------------------------
    33 // --------------------------------------------------------------------------
    28 // 
    34 // 
    29 // 2-phased constructor.
    35 // 2-phased constructor.
    30 // --------------------------------------------------------------------------
    36 // --------------------------------------------------------------------------
    54 // 
    60 // 
    55 // --------------------------------------------------------------------------
    61 // --------------------------------------------------------------------------
    56 //
    62 //
    57 void CPtpSession::ConstructL()
    63 void CPtpSession::ConstructL()
    58     {
    64     {
    59     __FLOG_OPEN(KMTPSubsystem, KPtpServerLog);
       
    60     iTimerP=CPtpTimer::NewL(*this);
    65     iTimerP=CPtpTimer::NewL(*this);
    61     }
    66     }
    62 // --------------------------------------------------------------------------
    67 // --------------------------------------------------------------------------
    63 // 
    68 // 
    64 // C++ destructor.
    69 // C++ destructor.
    65 // --------------------------------------------------------------------------
    70 // --------------------------------------------------------------------------
    66 //
    71 //
    67 CPtpSession::~CPtpSession()
    72 CPtpSession::~CPtpSession()
    68     {
    73     {
    69     __FLOG(_L8(">>>CPtpSession::~"));
    74     OstTraceFunctionEntry0( CPTPSESSION_CPTPSESSION_DES_ENTRY );
    70     delete iTimerP;
    75     delete iTimerP;
    71     CancelOutstandingRequest();
    76     CancelOutstandingRequest();
    72     TRAP_IGNORE(CleanupL()); // there is not much we can do at this phase if the removal fails, so just ignore
    77     TRAP_IGNORE(CleanupL()); // there is not much we can do at this phase if the removal fails, so just ignore
    73     if(iServerP->NumSession())
    78     if(iServerP->NumSession())
    74         {
    79         {
    75         iServerP->DecrementSessionCount();
    80         iServerP->DecrementSessionCount();
    76         }
    81         }
    77     __FLOG(_L8("<<<CPtpSession::~"));
    82     OstTraceFunctionExit0( CPTPSESSION_CPTPSESSION_DES_EXIT );
    78     __FLOG_CLOSE;
       
    79     }
    83     }
    80 
    84 
    81 // --------------------------------------------------------------------------
    85 // --------------------------------------------------------------------------
    82 // 
    86 // 
    83 // From CSession2, passes the request forward to DispatchMessageL.
    87 // From CSession2, passes the request forward to DispatchMessageL.
    84 // --------------------------------------------------------------------------
    88 // --------------------------------------------------------------------------
    85 //
    89 //
    86 void CPtpSession::ServiceL( const RMessage2& aMessage )
    90 void CPtpSession::ServiceL( const RMessage2& aMessage )
    87     {
    91     {
    88     __FLOG(_L8(">>>CPtpSession::ServiceL"));
    92     OstTraceFunctionEntry0( CPTPSESSION_SERVICEL_ENTRY );
    89     DispatchMessageL(aMessage);
    93     DispatchMessageL(aMessage);
    90     __FLOG(_L8("<<<CPtpSession::ServiceL"));
    94     OstTraceFunctionExit0( CPTPSESSION_SERVICEL_EXIT );
    91     }
    95     }
    92 
    96 
    93 // --------------------------------------------------------------------------
    97 // --------------------------------------------------------------------------
    94 //  Cleans up the previously received DPS file, since the files are used only 
    98 //  Cleans up the previously received DPS file, since the files are used only 
    95 //  for communication
    99 //  for communication
    96 // --------------------------------------------------------------------------
   100 // --------------------------------------------------------------------------
    97 //
   101 //
    98 void CPtpSession::CleanupL()
   102 void CPtpSession::CleanupL()
    99     {
   103     {
   100     __FLOG(_L8(">>>CPtpSession::Cleanup"));
   104     OstTraceFunctionEntry0( CPTPSESSION_CLEANUPL_ENTRY );
   101     if(iReceivedFile.Size())
   105     if(iReceivedFile.Size())
   102         {
   106         {
   103         __FLOG_VA((_L16("   deleting file %S"), &iReceivedFile));
   107         OstTraceExt1( TRACE_NORMAL, CPTPSESSION_CLEANUPL, "   deleting file %S", iReceivedFile );
   104         User::LeaveIfError(iServerP->Framework().Fs().Delete(iReceivedFile));
   108         LEAVEIFERROR(iServerP->Framework().Fs().Delete(iReceivedFile),
   105         __FLOG(_L8("   removing from DB"));
   109                 OstTrace1( TRACE_ERROR, DUP2_CPTPSESSION_CLEANUPL, "Delete file failed! error code %d", munged_err));
       
   110         OstTrace0( TRACE_NORMAL, DUP1_CPTPSESSION_CLEANUPL, "   removing from DB" );
   106         iServerP->RemoveObjectL(iReceivedFile);
   111         iServerP->RemoveObjectL(iReceivedFile);
   107         iReceivedFile.Zero();
   112         iReceivedFile.Zero();
   108         }
   113         }
   109     __FLOG(_L8("<<<CPtpSession::Cleanup"));
   114     OstTraceFunctionExit0( CPTPSESSION_CLEANUPL_EXIT );
   110     }
   115     }
   111 
   116 
   112 // --------------------------------------------------------------------------
   117 // --------------------------------------------------------------------------
   113 // Handles the request from client.
   118 // Handles the request from client.
   114 // --------------------------------------------------------------------------
   119 // --------------------------------------------------------------------------
   115 //
   120 //
   116 void CPtpSession::DispatchMessageL( const RMessage2& aMessage )
   121 void CPtpSession::DispatchMessageL( const RMessage2& aMessage )
   117     {
   122     {
   118     __FLOG_VA((_L8(">>>CPtpSession::DispatchMessageL %d"), aMessage.Function()));
   123     OstTraceFunctionEntry0( CPTPSESSION_DISPATCHMESSAGEL_ENTRY );
       
   124     OstTrace1( TRACE_NORMAL, CPTPSESSION_DISPATCHMESSAGEL, "aMessage.Function() %d", aMessage.Function());
       
   125 
   119     TInt ret = KErrNone;
   126     TInt ret = KErrNone;
   120     TBool complete = ETrue;        
   127     TBool complete = ETrue;        
   121     CleanupL(); // calling this here assumes that the client never makes a new call 
   128     CleanupL(); // calling this here assumes that the client never makes a new call 
   122                 // before it has handled the received DPS message
   129                 // before it has handled the received DPS message
   123     switch( aMessage.Function() )
   130     switch( aMessage.Function() )
   157         case EPtpFolder:
   164         case EPtpFolder:
   158             ret = PtpFolder(aMessage);
   165             ret = PtpFolder(aMessage);
   159             break;
   166             break;
   160 
   167 
   161         default:
   168         default:
   162             __FLOG(_L8("!!!Error: ---Wrong param from client!!!"));
   169             OstTrace0( TRACE_FATAL, DUP2_CPTPSESSION_DISPATCHMESSAGEL, "!!!Error: ---Wrong param from client!!!" );
   163             aMessage.Panic(KPTPClientPanicCategory, EBadRequest);
   170             aMessage.Panic(KPTPClientPanicCategory, EBadRequest);
   164             break;
   171             break;
   165         }
   172         }
   166         
   173         
   167     if (complete)
   174     if (complete)
   168         {
   175         {
   169         aMessage.Complete(ret);
   176         aMessage.Complete(ret);
   170         }
   177         }
   171     __FLOG_VA((_L8("<<<PtpSession::DispatchMessageL ret=%d"), ret));
   178     OstTrace1( TRACE_NORMAL, DUP1_CPTPSESSION_DISPATCHMESSAGEL, "ret=%d", ret );    
       
   179     OstTraceFunctionExit0( CPTPSESSION_DISPATCHMESSAGEL_EXIT );
   172     }
   180     }
   173 
   181 
   174 // --------------------------------------------------------------------------
   182 // --------------------------------------------------------------------------
   175 // CPtpSession::CancelIsDpsPrinter()
   183 // CPtpSession::CancelIsDpsPrinter()
   176 // Cancels Asynchronous request IsDpsPrinter
   184 // Cancels Asynchronous request IsDpsPrinter
   177 // --------------------------------------------------------------------------
   185 // --------------------------------------------------------------------------
   178 //
   186 //
   179 void CPtpSession::CancelIsDpsPrinter()
   187 void CPtpSession::CancelIsDpsPrinter()
   180     {
   188     {
   181     __FLOG(_L8(">>>CPtpSession::CancelIsDpsPrinter"));
   189     OstTraceFunctionEntry0( CPTPSESSION_CANCELISDPSPRINTER_ENTRY );
   182     if (iDpsPrinterMsg.Handle())
   190     if (iDpsPrinterMsg.Handle())
   183         {
   191         {
   184         iDpsPrinterMsg.Complete(KErrCancel);
   192         iDpsPrinterMsg.Complete(KErrCancel);
   185         iServerP->Printer()->DeRegisterDpsPrinterNotify(this);
   193         iServerP->Printer()->DeRegisterDpsPrinterNotify(this);
   186         iTimerP->Cancel();
   194         iTimerP->Cancel();
   187         iServerP->CancelNotifyOnMtpSessionOpen(this);
   195         iServerP->CancelNotifyOnMtpSessionOpen(this);
   188         } 
   196         } 
   189     __FLOG(_L8("<<<CPtpSession::CancelIsDpsPrinter"));
   197     OstTraceFunctionExit0( CPTPSESSION_CANCELISDPSPRINTER_EXIT );
   190     }
   198     }
   191     
   199     
   192 // --------------------------------------------------------------------------
   200 // --------------------------------------------------------------------------
   193 // CPtpSession::CancelSendObject()
   201 // CPtpSession::CancelSendObject()
   194 // Cancel Asynchronous request send Object
   202 // Cancel Asynchronous request send Object
   195 // --------------------------------------------------------------------------
   203 // --------------------------------------------------------------------------
   196 //
   204 //
   197 void CPtpSession::CancelSendObject()
   205 void CPtpSession::CancelSendObject()
   198     {
   206     {
   199     __FLOG(_L8(">>>CancelSendObject"));
   207     OstTraceFunctionEntry0( CPTPSESSION_CANCELSENDOBJECT_ENTRY );
   200     if (iSendObjectMsg.Handle())
   208     if (iSendObjectMsg.Handle())
   201         {
   209         {
   202         iServerP->Printer()->CancelSendDpsFile();
   210         iServerP->Printer()->CancelSendDpsFile();
   203         iSendObjectMsg.Complete(KErrCancel);
   211         iSendObjectMsg.Complete(KErrCancel);
   204         iTimerP->Cancel();
   212         iTimerP->Cancel();
   205         }
   213         }
   206     __FLOG(_L8("<<<CancelSendObject"));    
   214     OstTraceFunctionExit0( CPTPSESSION_CANCELSENDOBJECT_EXIT );
   207     }
   215     }
   208     
   216     
   209 // --------------------------------------------------------------------------
   217 // --------------------------------------------------------------------------
   210 // CPtpSession::CancelObjectReceivedNotify()
   218 // CPtpSession::CancelObjectReceivedNotify()
   211 // Deregisters for Object received notification
   219 // Deregisters for Object received notification
   212 // --------------------------------------------------------------------------
   220 // --------------------------------------------------------------------------
   213 //
   221 //
   214 void CPtpSession::CancelObjectReceivedNotify()
   222 void CPtpSession::CancelObjectReceivedNotify()
   215     {
   223     {
   216     __FLOG(_L8(">>>CancelObjectReceivedNotify"));       
   224     OstTraceFunctionEntry0( CPTPSESSION_CANCELOBJECTRECEIVEDNOTIFY_ENTRY );    
   217     if (iObjectReceivedNotifyMsg.Handle())
   225     if (iObjectReceivedNotifyMsg.Handle())
   218         {
   226         {
   219         __FLOG_VA((_L8("the handle is 0x%x"), iObjectReceivedNotifyMsg.Handle()));
   227         OstTrace1( TRACE_NORMAL, CPTPSESSION_CANCELOBJECTRECEIVEDNOTIFY, 
       
   228                 "the handle is 0x%x", iObjectReceivedNotifyMsg.Handle());
   220         iServerP->Printer()->MsgHandlerP()->DeRegisterReceiveObjectNotify();
   229         iServerP->Printer()->MsgHandlerP()->DeRegisterReceiveObjectNotify();
   221         iObjectReceivedNotifyMsg.Complete(KErrCancel);                    
   230         iObjectReceivedNotifyMsg.Complete(KErrCancel);                    
   222         }
   231         }
   223     __FLOG(_L8("<<<CancelObjectReceivedNotifiy"));
   232     OstTraceFunctionExit0( CPTPSESSION_CANCELOBJECTRECEIVEDNOTIFY_EXIT );
   224     }
   233     }
   225     
   234     
   226 // --------------------------------------------------------------------------
   235 // --------------------------------------------------------------------------
   227 // CPtpSession::IsDpsPrinter()
   236 // CPtpSession::IsDpsPrinter()
   228 // --------------------------------------------------------------------------
   237 // --------------------------------------------------------------------------
   229 //    
   238 //    
   230 TInt CPtpSession::IsDpsPrinter(const RMessage2& aMessage, TBool& aComplete)
   239 TInt CPtpSession::IsDpsPrinter(const RMessage2& aMessage, TBool& aComplete)
   231     {
   240     {
   232     __FLOG(_L8(">>>IsDpsPrinter"));
   241     OstTraceFunctionEntry0( CPTPSESSION_ISDPSPRINTER_ENTRY );
   233     TInt ret=EPrinterNotAvailable;
   242     TInt ret=EPrinterNotAvailable;
   234     if (!iDpsPrinterMsg.Handle()) // not already pending
   243     if (!iDpsPrinterMsg.Handle()) // not already pending
   235         {
   244         {
   236         switch (iServerP->Printer()->Status())
   245         switch (iServerP->Printer()->Status())
   237             {   
   246             {   
   249                 else
   258                 else
   250                     {
   259                     {
   251                     iServerP->NotifyOnMtpSessionOpen(this);
   260                     iServerP->NotifyOnMtpSessionOpen(this);
   252                     }                    
   261                     }                    
   253                 // we do not set ret since the  value does not really matter, we will be waiting for the discovery to complete
   262                 // we do not set ret since the  value does not really matter, we will be waiting for the discovery to complete
   254                 __FLOG(_L8(" waiting"));
   263                 OstTrace0( TRACE_NORMAL, CPTPSESSION_ISDPSPRINTER, " waiting" );
   255                 break;
   264                 break;
   256                 
   265                 
   257             case CMTPPictBridgePrinter::EConnected:
   266             case CMTPPictBridgePrinter::EConnected:
   258                 ret=EPrinterAvailable;
   267                 ret=EPrinterAvailable;
   259                 aComplete = ETrue;
   268                 aComplete = ETrue;
   260                 __FLOG(_L8(" connected"));
   269                 OstTrace0( TRACE_NORMAL, DUP1_CPTPSESSION_ISDPSPRINTER, " connected" );
   261                 break;
   270                 break;
   262 
   271 
   263             case CMTPPictBridgePrinter::ENotPrinter:
   272             case CMTPPictBridgePrinter::ENotPrinter:
   264                 ret=EPrinterNotAvailable;
   273                 ret=EPrinterNotAvailable;
   265                 aComplete = ETrue;
   274                 aComplete = ETrue;
   266                 __FLOG(_L8(" not connected"));
   275                 OstTrace0( TRACE_NORMAL, DUP2_CPTPSESSION_ISDPSPRINTER, " not connected" );
   267                 break;
   276                 break;
   268 
   277 
   269             default:
   278             default:
   270                 break;                
   279                 break;                
   271             }
   280             }
   272         }
   281         }
   273     else
   282     else
   274         {
   283         { 
   275         __FLOG(_L8("!!!Error: client message error, duplicated IsDpsPrinter"));                        
   284         OstTrace0( TRACE_FATAL, DUP3_CPTPSESSION_ISDPSPRINTER, "!!!Error: client message error, duplicated IsDpsPrinter" );
   276         aMessage.Panic(KPTPClientPanicCategory, ERequestPending);
   285         aMessage.Panic(KPTPClientPanicCategory, ERequestPending);
   277         aComplete = EFalse;
   286         aComplete = EFalse;
   278         }
   287         }
   279     __FLOG(_L8("<<<IsDpsPrinter"));
   288     OstTraceFunctionExit0( CPTPSESSION_ISDPSPRINTER_EXIT );
   280     return ret;
   289     return ret;
   281     }
   290     }
   282 
   291 
   283 // --------------------------------------------------------------------------
   292 // --------------------------------------------------------------------------
   284 // start the timer for printer detection, since we have now session open and 
   293 // start the timer for printer detection, since we have now session open and 
   285 // we are ready to communicate wioth the host
   294 // we are ready to communicate wioth the host
   286 // --------------------------------------------------------------------------
   295 // --------------------------------------------------------------------------
   287 void CPtpSession::MTPSessionOpened()
   296 void CPtpSession::MTPSessionOpened()
   288     {
   297     {
   289     __FLOG(_L8(">>>CPtpSession::MTPSessionOpened"));
   298     OstTraceFunctionEntry0( CPTPSESSION_MTPSESSIONOPENED_ENTRY );
   290     if (!iTimerP->IsActive() && iDpsPrinterMsg.Handle()) 
   299     if (!iTimerP->IsActive() && iDpsPrinterMsg.Handle()) 
   291         {
   300         {
   292         __FLOG(_L8("   CPtpSession::MTPSessionOpened timer started"));
   301         OstTrace0( TRACE_NORMAL, CPTPSESSION_MTPSESSIONOPENED, "timer started" );
   293         iTimerP->After(KDiscoveryTime);
   302         iTimerP->After(KDiscoveryTime);
   294         }        
   303         }        
   295     __FLOG(_L8("<<<CPtpSession::MTPSessionOpened"));
   304     OstTraceFunctionExit0( CPTPSESSION_MTPSESSIONOPENED_EXIT );
   296     }
   305     }
   297     
   306     
   298 // --------------------------------------------------------------------------
   307 // --------------------------------------------------------------------------
   299 // CPtpSession::GetObjectHandleByNameL()
   308 // CPtpSession::GetObjectHandleByNameL()
   300 // 
   309 // 
   301 // --------------------------------------------------------------------------
   310 // --------------------------------------------------------------------------
   302 //
   311 //
   303 void CPtpSession::GetObjectHandleByNameL(const RMessage2& aMessage)
   312 void CPtpSession::GetObjectHandleByNameL(const RMessage2& aMessage)
   304     {
   313     {
   305     __FLOG(_L8(">>>CPtpSession::GetObjectHandleByNameL"));
   314     OstTraceFunctionEntry0( CPTPSESSION_GETOBJECTHANDLEBYNAMEL_ENTRY );
   306     TFileName file;
   315     TFileName file;
   307     User::LeaveIfError(aMessage.Read(0, file));
   316     LEAVEIFERROR(aMessage.Read(0, file),
   308     __FLOG_VA((_L16("--the file is %S"), &file));
   317             OstTrace1( TRACE_ERROR, DUP2_CPTPSESSION_GETOBJECTHANDLEBYNAMEL, 
       
   318                     "Read file name from message failed! error code %d", munged_err ));
       
   319     OstTraceExt1( TRACE_NORMAL, DUP1_CPTPSESSION_GETOBJECTHANDLEBYNAMEL, "--the file is %S", file );
   309     TUint32 handle=0;
   320     TUint32 handle=0;
   310     TRAP_IGNORE(iServerP->GetObjectHandleByNameL(file, handle));
   321     TRAP_IGNORE(iServerP->GetObjectHandleByNameL(file, handle));
   311     TPckgBuf<TUint32> handlePckg(handle);
   322     TPckgBuf<TUint32> handlePckg(handle);
   312     aMessage.WriteL(1, handlePckg);     
   323     aMessage.WriteL(1, handlePckg);     
   313     __FLOG_VA((_L16("<<<CPtpSession::GetObjectHandleByNameL handle=%d"), handle));
   324     OstTrace1( TRACE_NORMAL, CPTPSESSION_GETOBJECTHANDLEBYNAMEL, "handle=%d", handle );    
       
   325     OstTraceFunctionExit0( CPTPSESSION_GETOBJECTHANDLEBYNAMEL_EXIT );
   314     }
   326     }
   315     
   327     
   316 // --------------------------------------------------------------------------
   328 // --------------------------------------------------------------------------
   317 // CPtpSession::GetNameByObjectHandle()
   329 // CPtpSession::GetNameByObjectHandle()
   318 
   330 
   319 // --------------------------------------------------------------------------
   331 // --------------------------------------------------------------------------
   320 //
   332 //
   321 void CPtpSession::GetNameByObjectHandleL(const RMessage2& aMessage)
   333 void CPtpSession::GetNameByObjectHandleL(const RMessage2& aMessage)
   322     {
   334     {
   323     __FLOG(_L8(">>>CPtpSession::GetNameByObjectHandle"));               
   335     OstTraceFunctionEntry0( CPTPSESSION_GETNAMEBYOBJECTHANDLEL_ENTRY );            
   324     TUint32 handle = 0;
   336     TUint32 handle = 0;
   325     TPckgBuf<TUint32> pckgHandle(handle);
   337     TPckgBuf<TUint32> pckgHandle(handle);
   326     User::LeaveIfError(aMessage.Read(1, pckgHandle));
   338     LEAVEIFERROR(aMessage.Read(1, pckgHandle),
       
   339             OstTrace1( TRACE_ERROR, CPTPSESSION_GETNAMEBYOBJECTHANDLEL, 
       
   340                     "Read handle from message failed! error code %d", munged_err ));
   327     TFileName file; 
   341     TFileName file; 
   328     handle = pckgHandle();
   342     handle = pckgHandle();
   329     __FLOG_VA((_L8("---handle is %x"), handle));
   343     OstTrace1( TRACE_NORMAL, DUP1_CPTPSESSION_GETNAMEBYOBJECTHANDLEL, "---handle is %x", handle );
   330     TRAP_IGNORE(iServerP->GetObjectNameByHandleL(file, handle));
   344     TRAP_IGNORE(iServerP->GetObjectNameByHandleL(file, handle));
   331     __FLOG_VA((_L16("the file is %S"), &file));
   345     OstTraceExt1( TRACE_NORMAL, DUP2_CPTPSESSION_GETNAMEBYOBJECTHANDLEL, "the file is %S", file );
   332     aMessage.WriteL(0, file);
   346     aMessage.WriteL(0, file);
   333     
   347           
   334     __FLOG(_L8("<<<CPtpSession::GetNameByObjectHandle"));               
   348     OstTraceFunctionExit0( CPTPSESSION_GETNAMEBYOBJECTHANDLEL_EXIT );
   335     }
   349     }
   336               
   350               
   337 // --------------------------------------------------------------------------
   351 // --------------------------------------------------------------------------
   338 // CPtpSession::SendObject()
   352 // CPtpSession::SendObject()
   339 // Asynch. request send Object
   353 // Asynch. request send Object
   340 // --------------------------------------------------------------------------
   354 // --------------------------------------------------------------------------
   341 //
   355 //
   342 TInt CPtpSession::SendObject(const RMessage2& aMessage, TBool& aComplete)
   356 TInt CPtpSession::SendObject(const RMessage2& aMessage, TBool& aComplete)
   343     {
   357     {
   344     __FLOG(_L8(">>>CPtpSession::SendObject"));                      
   358     OstTraceFunctionEntry0( CPTPSESSION_SENDOBJECT_ENTRY );               
   345     TInt err(KErrNone);
   359     TInt err(KErrNone);
   346     
   360     
   347     if (iSendObjectMsg.Handle())
   361     if (iSendObjectMsg.Handle())
   348         {
   362         {
   349         __FLOG(_L8("!!!!Error: client message error, duplicated SendObject"));
   363         OstTrace0( TRACE_FATAL, DUP1_CPTPSESSION_SENDOBJECT, "!!!!Error: client message error, duplicated SendObject" );
   350         aMessage.Panic(KPTPClientPanicCategory, ERequestPending);
   364         aMessage.Panic(KPTPClientPanicCategory, ERequestPending);
   351         aComplete = EFalse;
   365         aComplete = EFalse;
       
   366         OstTraceFunctionExit0( CPTPSESSION_SENDOBJECT_EXIT );
   352         return KErrNone;
   367         return KErrNone;
   353         }
   368         }
   354     else
   369     else
   355         {
   370         {
   356         // Parameter add is depracated. We do not send Object added and we do not keep ther DPS object permanently in
   371         // Parameter add is depracated. We do not send Object added and we do not keep ther DPS object permanently in
   357         // our system.
   372         // our system.
   358         //
   373         //
   359         // Sending ObjectAdded Event is not mandatory ( See Appendix B page 78. DPS Usage of USB and PTP in CIPA DC-001-2003)
   374         // Sending ObjectAdded Event is not mandatory ( See Appendix B page 78. DPS Usage of USB and PTP in CIPA DC-001-2003)
   360 
   375 
   361         TBool timeout = aMessage.Int2();    
   376         TBool timeout = aMessage.Int2();       
   362         __FLOG_VA((_L8("---timeout is %d"), timeout));    
   377         OstTrace1( TRACE_NORMAL, DUP2_CPTPSESSION_SENDOBJECT, "---timeout is %d", timeout );
   363         TFileName file; 
   378         TFileName file; 
   364         err = aMessage.Read(0, file);
   379         err = aMessage.Read(0, file);
   365         if (err == KErrNone)
   380         if (err == KErrNone)
   366             {
   381             {
   367             __FLOG_VA((_L16("---the file is %S"), &file));
   382             OstTraceExt1( TRACE_NORMAL, DUP3_CPTPSESSION_SENDOBJECT, "---the file is %S", file );
   368             TInt size = aMessage.Int3();
   383             TInt size = aMessage.Int3();
   369             __FLOG_VA((_L8("---the file size is %d"), size)); // size is deprecated and not used anymore
   384             // size is deprecated and not used anymore
       
   385             OstTrace1( TRACE_NORMAL, DUP4_CPTPSESSION_SENDOBJECT, "---the file size is %d", size );
   370             TRAP(err, iServerP->Printer()->SendDpsFileL(file, timeout, size));
   386             TRAP(err, iServerP->Printer()->SendDpsFileL(file, timeout, size));
   371             if (err == KErrNone)
   387             if (err == KErrNone)
   372                 {
   388                 {
   373                 iSendObjectMsg = aMessage;
   389                 iSendObjectMsg = aMessage;
   374                 aComplete = EFalse;    
   390                 aComplete = EFalse;    
   376             }
   392             }
   377         if ((EFalse != timeout) && !iTimerP->IsActive())
   393         if ((EFalse != timeout) && !iTimerP->IsActive())
   378             {
   394             {
   379             iTimerP->After(KSendTimeout);
   395             iTimerP->After(KSendTimeout);
   380             }
   396             }
   381         __FLOG_VA((_L8("<<<CPtpSession::SendObject err=%d"), err));
   397         OstTrace1( TRACE_NORMAL, CPTPSESSION_SENDOBJECT, "err=%d", err );        
       
   398         OstTraceFunctionExit0( DUP1_CPTPSESSION_SENDOBJECT_EXIT );
   382         return err;    
   399         return err;    
   383         }    
   400         }    
   384     }             
   401     }             
   385 
   402 
   386 // --------------------------------------------------------------------------
   403 // --------------------------------------------------------------------------
   389 // --------------------------------------------------------------------------
   406 // --------------------------------------------------------------------------
   390 //   
   407 //   
   391 TInt CPtpSession::ObjectReceivedNotify(const RMessage2& aMessage, 
   408 TInt CPtpSession::ObjectReceivedNotify(const RMessage2& aMessage, 
   392                                        TBool& aComplete)
   409                                        TBool& aComplete)
   393     {
   410     {
   394     __FLOG(_L8(">>>CPtpSession::ObjectReceivedNotify"));                        
   411     OstTraceFunctionEntry0( CPTPSESSION_OBJECTRECEIVEDNOTIFY_ENTRY );                      
   395     if (iObjectReceivedNotifyMsg.Handle())
   412     if (iObjectReceivedNotifyMsg.Handle())
   396         {
   413         {
   397         __FLOG(_L8("!!!!Error: client message error, duplicated ObjectReceivedNotify"));
   414         OstTrace0( TRACE_FATAL, CPTPSESSION_OBJECTRECEIVEDNOTIFY, "!!!!Error: client message error, duplicated ObjectReceivedNotify" );
   398         aMessage.Panic(KPTPClientPanicCategory, ERequestPending);
   415         aMessage.Panic(KPTPClientPanicCategory, ERequestPending);
   399         aComplete = EFalse;
   416         aComplete = EFalse;
       
   417         OstTraceFunctionExit0( CPTPSESSION_OBJECTRECEIVEDNOTIFY_EXIT );
   400         return KErrNone;
   418         return KErrNone;
   401         }
   419         }
   402     else
   420     else
   403         {
   421         {
   404         //TBool del = aMessage.Int2();
   422         //TBool del = aMessage.Int2(); 
   405         //__FLOG_VA((_L8("---the del is %d"), del));    
       
   406 
   423 
   407         TBuf<KFileExtLength> ext; 
   424         TBuf<KFileExtLength> ext; 
   408         TInt err = aMessage.Read(0, ext);
   425         TInt err = aMessage.Read(0, ext);
   409         if (err == KErrNone)
   426         if (err == KErrNone)
   410             {
   427             {
   411             __FLOG_VA((_L16("the extension is %S"), &ext));
   428             OstTraceExt1( TRACE_NORMAL, DUP1_CPTPSESSION_OBJECTRECEIVEDNOTIFY, "the extension is %S", ext);
   412             
   429 
   413             iObjectReceivedNotifyMsg = aMessage; 
   430             iObjectReceivedNotifyMsg = aMessage; 
   414             aComplete = EFalse;
   431             aComplete = EFalse;
   415             iServerP->Printer()->MsgHandlerP()->RegisterReceiveObjectNotify(ext);
   432             iServerP->Printer()->MsgHandlerP()->RegisterReceiveObjectNotify(ext);
   416             }
   433             }                          
   417         __FLOG(_L8("<<<CPtpSession::ObjectReceivedNotify"));                            
   434         OstTraceFunctionExit0( DUP1_CPTPSESSION_OBJECTRECEIVEDNOTIFY_EXIT );
   418         return err;
   435         return err;
   419         }
   436         }
   420     }
   437     }
   421     
   438     
   422 // --------------------------------------------------------------------------
   439 // --------------------------------------------------------------------------
   424 // Returns PtpFolder Name and Path
   441 // Returns PtpFolder Name and Path
   425 // --------------------------------------------------------------------------
   442 // --------------------------------------------------------------------------
   426 //    
   443 //    
   427 TInt CPtpSession::PtpFolder(const RMessage2& aMessage)
   444 TInt CPtpSession::PtpFolder(const RMessage2& aMessage)
   428     {
   445     {
   429     __FLOG(_L8(">>>CPtpSession::PtpFolder"));
   446     OstTraceFunctionEntry0( CPTPSESSION_PTPFOLDER_ENTRY );
   430     TInt err(KErrNotReady);
   447     TInt err(KErrNotReady);
   431     TFileName folder = iServerP->PtpFolder();
   448     TFileName folder = iServerP->PtpFolder();
   432     err = aMessage.Write(0,folder);
   449     err = aMessage.Write(0,folder);
   433     __FLOG_VA((_L16("<<<CPtpSession::PtpFolder %S err(%d)"), &folder, err));
   450     OstTraceExt2( TRACE_NORMAL, CPTPSESSION_PTPFOLDER, "Folder %S err(%d)", folder, err);    
       
   451     OstTraceFunctionExit0( CPTPSESSION_PTPFOLDER_EXIT );
   434     return err;
   452     return err;
   435     }
   453     }
   436     
   454     
   437 // --------------------------------------------------------------------------
   455 // --------------------------------------------------------------------------
   438 // CPtpSession::SendObjectCompleted()
   456 // CPtpSession::SendObjectCompleted()
   439 // 
   457 // 
   440 // --------------------------------------------------------------------------
   458 // --------------------------------------------------------------------------
   441 //    
   459 //    
   442 void CPtpSession::SendObjectCompleted(TInt aStatus)
   460 void CPtpSession::SendObjectCompleted(TInt aStatus)
   443     {
   461     {
   444     __FLOG_VA((_L16(">>>CPtpSession::SendObjectCompleted status(%d)"), aStatus));
   462     OstTraceFunctionEntry0( CPTPSESSION_SENDOBJECTCOMPLETED_ENTRY );
       
   463     OstTrace1( TRACE_NORMAL, CPTPSESSION_SENDOBJECTCOMPLETED, "status(%d)", aStatus );
   445     if (iSendObjectMsg.Handle())
   464     if (iSendObjectMsg.Handle())
   446         {
   465         {
   447         iSendObjectMsg.Complete(aStatus);    
   466         iSendObjectMsg.Complete(aStatus);    
   448         iTimerP->Cancel();
   467         iTimerP->Cancel();
   449         }
   468         }
   450     else
   469     else
   451         {
   470         {
   452         __FLOG(_L8("!!!Warning: CPtpSession::SendObjectCompleted: UNEXPECTED CALL"));
   471         OstTrace0( TRACE_WARNING, DUP1_CPTPSESSION_SENDOBJECTCOMPLETED, "!!!Warning: UNEXPECTED CALL" );
   453         }
   472         }
   454     __FLOG(_L8("<<<CPtpSession::SendObjectCompleted")); 
   473     OstTraceFunctionExit0( CPTPSESSION_SENDOBJECTCOMPLETED_EXIT );
   455     }
   474     }
   456 
   475 
   457 // --------------------------------------------------------------------------
   476 // --------------------------------------------------------------------------
   458 // CPtpSession::IsDpsPrinterCompleted()
   477 // CPtpSession::IsDpsPrinterCompleted()
   459 // 
   478 // 
   460 // --------------------------------------------------------------------------
   479 // --------------------------------------------------------------------------
   461 //
   480 //
   462 void CPtpSession::IsDpsPrinterCompleted(TDpsPrinterState aState)
   481 void CPtpSession::IsDpsPrinterCompleted(TDpsPrinterState aState)
   463     {
   482     {
   464     __FLOG(_L8(">>>CPtpSession::IsDpsPrinterCompleted"));    
   483     OstTraceFunctionEntry0( CPTPSESSION_ISDPSPRINTERCOMPLETED_ENTRY );  
   465     if (iDpsPrinterMsg.Handle())
   484     if (iDpsPrinterMsg.Handle())
   466         {
   485         {
   467         iDpsPrinterMsg.Complete(aState);
   486         iDpsPrinterMsg.Complete(aState);
   468         iTimerP->Cancel();
   487         iTimerP->Cancel();
   469         iServerP->Printer()->DeRegisterDpsPrinterNotify(this);
   488         iServerP->Printer()->DeRegisterDpsPrinterNotify(this);
   470         }
   489         }
   471     else
   490     else
   472         {
   491         {
   473         __FLOG(_L8("!!!Warning: CPtpSession::IsDpsPrinterCompleted: UNEXPECTED CALL"));
   492         OstTrace0( TRACE_WARNING, CPTPSESSION_ISDPSPRINTERCOMPLETED, "!!!Warning:  UNEXPECTED CALL" );
   474         }
   493         } 
   475     __FLOG(_L8("<<<CPtpSession::IsDpsPrinterCompleted"));    
   494     OstTraceFunctionExit0( CPTPSESSION_ISDPSPRINTERCOMPLETED_EXIT );
   476     }
   495     }
   477 
   496 
   478 // --------------------------------------------------------------------------
   497 // --------------------------------------------------------------------------
   479 // CPtpSession::ReceivedObjectCompleted()
   498 // CPtpSession::ReceivedObjectCompleted()
   480 // 
   499 // 
   481 // --------------------------------------------------------------------------
   500 // --------------------------------------------------------------------------
   482 //
   501 //
   483 void CPtpSession::ReceivedObjectCompleted(TDes& aFile)
   502 void CPtpSession::ReceivedObjectCompleted(TDes& aFile)
   484     {
   503     {
   485     __FLOG(_L8(">>>CPtpSession::ReceivedObjectCompleted"));
   504     OstTraceFunctionEntry0( CPTPSESSION_RECEIVEDOBJECTCOMPLETED_ENTRY );
   486     if (iObjectReceivedNotifyMsg.Handle())
   505     if (iObjectReceivedNotifyMsg.Handle())
   487         {
   506         {
   488         TInt err = iObjectReceivedNotifyMsg.Write(1, aFile);
   507         TInt err = iObjectReceivedNotifyMsg.Write(1, aFile);
   489         iReceivedFile.Copy(aFile);
   508         iReceivedFile.Copy(aFile);
   490         __FLOG_VA((_L8("***CPtpSession::ReceivedObjectCompleted err=%d"), err));
   509         OstTrace1( TRACE_NORMAL, CPTPSESSION_RECEIVEDOBJECTCOMPLETED, "*** err=%d", err );
   491         iObjectReceivedNotifyMsg.Complete(err);
   510         iObjectReceivedNotifyMsg.Complete(err);
   492         }
   511         }
   493     else
   512     else
   494         {
   513         {
   495         __FLOG(_L8("!!!Warning: Strange Happened!!!"));    
   514         OstTrace0( TRACE_WARNING, DUP1_CPTPSESSION_RECEIVEDOBJECTCOMPLETED, "!!!Warning: Strange Happened!!!" );
   496         }
   515         }
   497     __FLOG(_L8("<<<CPtpSession::ReceivedObjectCompleted"));
   516     OstTraceFunctionExit0( CPTPSESSION_RECEIVEDOBJECTCOMPLETED_EXIT );
   498     }
   517     }
   499 
   518 
   500 // --------------------------------------------------------------------------
   519 // --------------------------------------------------------------------------
   501 // 
   520 // 
   502 // Cancels outstanding request
   521 // Cancels outstanding request
   503 // --------------------------------------------------------------------------
   522 // --------------------------------------------------------------------------
   504 //
   523 //
   505 void CPtpSession::CancelOutstandingRequest()
   524 void CPtpSession::CancelOutstandingRequest()
   506     {
   525     {
   507     __FLOG(_L8(">>>CPtpSession::CancelOutstandingRequest"));
   526     OstTraceFunctionEntry0( CPTPSESSION_CANCELOUTSTANDINGREQUEST_ENTRY );
   508     if (iSendObjectMsg.Handle())
   527     if (iSendObjectMsg.Handle())
   509         {
   528         {
   510         iSendObjectMsg.Complete(KErrCancel);
   529         iSendObjectMsg.Complete(KErrCancel);
   511         }
   530         }
   512     if (iObjectReceivedNotifyMsg.Handle())
   531     if (iObjectReceivedNotifyMsg.Handle())
   515         }
   534         }
   516     if (iDpsPrinterMsg.Handle())
   535     if (iDpsPrinterMsg.Handle())
   517         {
   536         {
   518         iDpsPrinterMsg.Complete(KErrCancel);
   537         iDpsPrinterMsg.Complete(KErrCancel);
   519         }
   538         }
   520     __FLOG(_L8("<<<CPtpSession::CancelOutstandingRequest"));    
   539     OstTraceFunctionExit0( CPTPSESSION_CANCELOUTSTANDINGREQUEST_EXIT );
   521     }
   540     }
   522 // --------------------------------------------------------------------------
   541 // --------------------------------------------------------------------------
   523 // 
   542 // 
   524 // --------------------------------------------------------------------------
   543 // --------------------------------------------------------------------------
   525 //
   544 //