telephonyserverplugins/common_tsy/commontsy/src/mmfax/CMmFaxExt.cpp
branchRCL_3
changeset 65 630d2f34d719
parent 0 3553901f7fa8
child 66 07a122eea281
equal deleted inserted replaced
61:17af172ffa5f 65:630d2f34d719
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    14 //
    14 //
    15 
    15 
    16 
    16 
    17 
    17 
    18 //  INCLUDE FILES
    18 //  INCLUDE FILES
    19 #include <ctsy/tflogger.h>
       
    20 #include "cmmfaxext.h"
    19 #include "cmmfaxext.h"
    21 #include "cmmphonetsy.h"
    20 #include "cmmphonetsy.h"
    22 #include "cmmlinelist.h"
    21 #include "cmmlinelist.h"
    23 #include "cmmfaxcalltsy.h"
    22 #include "cmmfaxcalltsy.h"
    24 #include "cmmfaxlinetsy.h"
    23 #include "cmmfaxlinetsy.h"
    30 
    29 
    31 CMmFaxExt::CMmFaxExt(
    30 CMmFaxExt::CMmFaxExt(
    32     CMmCallTsy* aMmCall )   // call that owns this object
    31     CMmCallTsy* aMmCall )   // call that owns this object
    33     : iMmCall( reinterpret_cast<CMmFaxCallTsy*>( aMmCall ) )
    32     : iMmCall( reinterpret_cast<CMmFaxCallTsy*>( aMmCall ) )
    34     {
    33     {
    35 TFLOGSTRING2("TSY: CMmFaxExt::CMmFaxExt: Call Id:%d", iMmCall->CallId() );
    34 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMFAXEXT_CTOR_1, "TSY: CMmFaxExt::CMmFaxExt: Call Id:%d", iMmCall->CallId() );
    36     iFax           = NULL;
    35     iFax           = NULL;
    37     iFaxSession    = NULL;
    36     iFaxSession    = NULL;
    38     iFaxCompletion = NULL;
    37     iFaxCompletion = NULL;
    39     }
    38     }
    40 
    39 
    41 void CMmFaxExt::ConstructL()
    40 void CMmFaxExt::ConstructL()
    42     {
    41     {
    43 TFLOGSTRING("TSY: CMmFaxExt::ConstructL");
    42 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMFAXEXT_CONSTRUCTL_1, "TSY: CMmFaxExt::ConstructL");
    44 
    43 
    45     // Create CMmFaxCompletion class for Fax Server.
    44     // Create CMmFaxCompletion class for Fax Server.
    46     iFaxCompletion = new (ELeave) CMmFaxCompletion();
    45     iFaxCompletion = new (ELeave) CMmFaxCompletion();
    47     iDataPortLoaned = EFalse;
    46     iDataPortLoaned = EFalse;
    48     }
    47     }
    49 
    48 
    50 CMmFaxExt* CMmFaxExt::NewL(
    49 CMmFaxExt* CMmFaxExt::NewL(
    51         CMmCallTsy* aMmCall )  // The call object which owns CMmFaxExt  
    50         CMmCallTsy* aMmCall )  // The call object which owns CMmFaxExt  
    52     {
    51     {
    53 TFLOGSTRING("TSY: CMmFaxExt::NewL");
    52 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMFAXEXT_NEWL_1, "TSY: CMmFaxExt::NewL");
    54 
    53 
    55     CMmFaxExt* self = new ( ELeave ) CMmFaxExt( aMmCall );
    54     CMmFaxExt* self = new ( ELeave ) CMmFaxExt( aMmCall );
    56     CleanupStack::PushL( self );
    55     CleanupStack::PushL( self );
    57     self->ConstructL();
    56     self->ConstructL();
    58     CleanupStack::Pop();
    57     CleanupStack::Pop();
    67     //cleanup multiple times.
    66     //cleanup multiple times.
    68     CleanUpFaxServer();
    67     CleanUpFaxServer();
    69 
    68 
    70     if ( iFax )
    69     if ( iFax )
    71         {
    70         {
    72 TFLOGSTRING("TSY: CMmFaxExt::~CMmFaxExt: deleting iFax");
    71 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMFAXEXT_DTOR_1, "TSY: CMmFaxExt::~CMmFaxExt: deleting iFax");
    73         delete iFax;
    72         delete iFax;
    74         iFax = NULL;
    73         iFax = NULL;
    75         }
    74         }
    76 
    75 
    77     if (iFaxCompletion)
    76     if (iFaxCompletion)
    78         {
    77         {
    79 TFLOGSTRING("TSY: CMmFaxExt::~CMmFaxExt: deleting iFaxCompletion");
    78 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMFAXEXT_DTOR_2, "TSY: CMmFaxExt::~CMmFaxExt: deleting iFaxCompletion");
    80         delete iFaxCompletion;
    79         delete iFaxCompletion;
    81         iFaxCompletion = NULL;
    80         iFaxCompletion = NULL;
    82         }
    81         }
    83 
    82 
    84     // mark fax as unopened, so that it can be opened again.
    83     // mark fax as unopened, so that it can be opened again.
    99 // ---------------------------------------------------------------------------
    98 // ---------------------------------------------------------------------------
   100 //
    99 //
   101 void CMmFaxExt::CompleteOperation(
   100 void CMmFaxExt::CompleteOperation(
   102         TInt aError ) 
   101         TInt aError ) 
   103     {
   102     {
   104 TFLOGSTRING("TSY: CMmFaxExt::CompleteOperation");
   103 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMFAXEXT_COMPLETEOPERATION_1, "TSY: CMmFaxExt::CompleteOperation");
   105      
   104      
   106     if ( iFaxCompletion )
   105     if ( iFaxCompletion )
   107         {
   106         {
   108         iFaxCompletion->CompleteOperation( aError );
   107         iFaxCompletion->CompleteOperation( aError );
   109         }
   108         }
   117 //
   116 //
   118 void CMmFaxExt::ConfigureCompletion(
   117 void CMmFaxExt::ConfigureCompletion(
   119         const TTsyReqHandle aTsyReqHandle,  
   118         const TTsyReqHandle aTsyReqHandle,  
   120         CTelObject* aTelObject )            
   119         CTelObject* aTelObject )            
   121     {
   120     {
   122 TFLOGSTRING("TSY: CMmFaxExt::Configure");
   121 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMFAXEXT_CONFIGURECOMPLETION_1, "TSY: CMmFaxExt::Configure");
   123 
   122 
   124     iFaxCompletion->Configure( aTsyReqHandle, aTelObject );
   123     iFaxCompletion->Configure( aTsyReqHandle, aTelObject );
   125     }
   124     }
   126 
   125 
   127 // ---------------------------------------------------------------------------
   126 // ---------------------------------------------------------------------------
   131 // ---------------------------------------------------------------------------
   130 // ---------------------------------------------------------------------------
   132 //
   131 //
   133 CTelObject* CMmFaxExt::OpenNewObjectByNameL(
   132 CTelObject* CMmFaxExt::OpenNewObjectByNameL(
   134         const TDesC& aName )  
   133         const TDesC& aName )  
   135     {
   134     {
   136 TFLOGSTRING("TSY: CMmFaxExt::OpenNewObjectByNameL");
   135 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMFAXEXT_OPENNEWOBJECTBYNAMEL_1, "TSY: CMmFaxExt::OpenNewObjectByNameL");
   137 
   136 
   138     // check the name of opened object..
   137     // check the name of opened object..
   139     _LIT(KFaxObjectName, "FAX");
   138     _LIT(KFaxObjectName, "FAX");
   140     if ( aName != KFaxObjectName )
   139     if ( aName != KFaxObjectName )
   141         {
   140         {
   178 // Returns: Error value
   177 // Returns: Error value
   179 // ---------------------------------------------------------------------------
   178 // ---------------------------------------------------------------------------
   180 //
   179 //
   181 TInt CMmFaxExt::FaxConnectHandler()
   180 TInt CMmFaxExt::FaxConnectHandler()
   182     {
   181     {
   183 TFLOGSTRING("TSY: CMmFaxExt::FaxConnectHandler");
   182 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMFAXEXT_FAXCONNECTHANDLER_1, "TSY: CMmFaxExt::FaxConnectHandler");
   184 
   183 
   185     TInt errorCode( KErrNone );
   184     TInt errorCode( KErrNone );
   186 
   185 
   187     if ( (reinterpret_cast<CMmFaxLineTsy*>( iMmCall->Line() ))->iFaxOpened 
   186     if ( (reinterpret_cast<CMmFaxLineTsy*>( iMmCall->Line() ))->iFaxOpened 
   188           && NULL == iFax )
   187           && NULL == iFax )
   208 // ---------------------------------------------------------------------------
   207 // ---------------------------------------------------------------------------
   209 //
   208 //
   210 TInt CMmFaxExt::AnswerIncomingCall(
   209 TInt CMmFaxExt::AnswerIncomingCall(
   211         const TTsyReqHandle& aTsyReqHandle ) // function identification handle
   210         const TTsyReqHandle& aTsyReqHandle ) // function identification handle
   212     {
   211     {
   213 TFLOGSTRING("TSY: CMmFaxExt::AnswerIncomingCall");
   212 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMFAXEXT_ANSWERINCOMINGCALL_1, "TSY: CMmFaxExt::AnswerIncomingCall");
   214     
   213     
   215     TInt ret( KErrGeneral );
   214     TInt ret( KErrGeneral );
   216 
   215 
   217     // check and set call ownership..
   216     // check and set call ownership..
   218     MCallBaseTSY::TCallOwnership ownerShip = iMmCall->CheckOwnership( 
   217     MCallBaseTSY::TCallOwnership ownerShip = iMmCall->CheckOwnership( 
   253 //
   252 //
   254 TInt CMmFaxExt::Dial(
   253 TInt CMmFaxExt::Dial(
   255         const TTsyReqHandle& aTsyReqHandle, 
   254         const TTsyReqHandle& aTsyReqHandle, 
   256         TDesC* aTelNumber )      
   255         TDesC* aTelNumber )      
   257     {
   256     {
   258 TFLOGSTRING("TSY: CMmFaxExt::Dial");
   257 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMFAXEXT_DIAL_1, "TSY: CMmFaxExt::Dial");
   259     
   258     
   260     TInt ret( KErrGeneral );
   259     TInt ret( KErrGeneral );
   261 
   260 
   262     // check and set call ownership..
   261     // check and set call ownership..
   263     MCallBaseTSY::TCallOwnership ownerShip = iMmCall->CheckOwnership( 
   262     MCallBaseTSY::TCallOwnership ownerShip = iMmCall->CheckOwnership( 
   292             if( KErrNone == ret )
   291             if( KErrNone == ret )
   293                 {
   292                 {
   294                 ConfigureCompletion( aTsyReqHandle, iMmCall );
   293                 ConfigureCompletion( aTsyReqHandle, iMmCall );
   295                 if( EDialAndTransmit == faxMode )
   294                 if( EDialAndTransmit == faxMode )
   296                     {
   295                     {
   297 TFLOGSTRING("TSY: CMmFaxExt::FaxDial:TxConnect");
   296 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMFAXEXT_DIAL_2, "TSY: CMmFaxExt::FaxDial:TxConnect");
   298                     iFaxSession->TxConnect();
   297                     iFaxSession->TxConnect();
   299                     }
   298                     }
   300                 else
   299                 else
   301                     {
   300                     {
   302 TFLOGSTRING("TSY: CMmFaxExt::FaxDial:RxConnect");
   301 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMFAXEXT_DIAL_3, "TSY: CMmFaxExt::FaxDial:RxConnect");
   303                     iFaxSession->RxConnect();
   302                     iFaxSession->RxConnect();
   304                     }
   303                     }
   305                 }
   304                 }
   306             } // faxconnect
   305             } // faxconnect
   307         }
   306         }
   320 // Returns:None
   319 // Returns:None
   321 // ---------------------------------------------------------------------------
   320 // ---------------------------------------------------------------------------
   322 //
   321 //
   323 void CMmFaxExt::HangUp()
   322 void CMmFaxExt::HangUp()
   324     {
   323     {
   325 TFLOGSTRING("TSY: CMmFaxExt::HangUp");
   324 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMFAXEXT_HANGUP_1, "TSY: CMmFaxExt::HangUp");
   326     CleanUpFaxServer();
   325     CleanUpFaxServer();
   327     }
   326     }
   328 
   327 
   329 // ---------------------------------------------------------------------------
   328 // ---------------------------------------------------------------------------
   330 // CMmFaxExt::FaxSession
   329 // CMmFaxExt::FaxSession
   343 // Returns:None 
   342 // Returns:None 
   344 // ---------------------------------------------------------------------------
   343 // ---------------------------------------------------------------------------
   345 //
   344 //
   346 void CMmFaxExt::GetFaxBaseL()
   345 void CMmFaxExt::GetFaxBaseL()
   347     {
   346     {
   348 TFLOGSTRING("TSY: CMmFaxExt::GetFaxBaseL");
   347 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMFAXEXT_GETFAXBASEL_1, "TSY: CMmFaxExt::GetFaxBaseL");
   349 
   348 
   350     TInt errorCode = iFaxServerLib.Load( KFaxServerName );
   349     TInt errorCode = iFaxServerLib.Load( KFaxServerName );
   351 
   350 
   352     if ( KErrNone == errorCode )
   351     if ( KErrNone == errorCode )
   353         {
   352         {
   409 //
   408 //
   410 TInt CMmFaxExt::OpenFaxServer(
   409 TInt CMmFaxExt::OpenFaxServer(
   411         const TDesC* aTelNumber,  // phone number
   410         const TDesC* aTelNumber,  // phone number
   412         const TFaxMode aFaxMode ) // fax mode
   411         const TFaxMode aFaxMode ) // fax mode
   413     {
   412     {
   414 TFLOGSTRING("TSY: CMmFaxExt::OpenFaxServer");
   413 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMFAXEXT_OPENFAXSERVER_1, "TSY: CMmFaxExt::OpenFaxServer");
   415 
   414 
   416     TInt errorCode ( KErrNone );
   415     TInt errorCode ( KErrNone );
   417     TFaxServerSessionSettings faxSettings;
   416     TFaxServerSessionSettings faxSettings;
   418     if ( aTelNumber )
   417     if ( aTelNumber )
   419         {
   418         {
   514 // Returns: None 
   513 // Returns: None 
   515 // ---------------------------------------------------------------------------
   514 // ---------------------------------------------------------------------------
   516 //
   515 //
   517 void CMmFaxExt::CleanUpFaxServer()
   516 void CMmFaxExt::CleanUpFaxServer()
   518     {
   517     {
   519 TFLOGSTRING("TSY: CMmFaxExt::CleanUpFaxServer");
   518 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMFAXEXT_CLEANUPFAXSERVER_1, "TSY: CMmFaxExt::CleanUpFaxServer");
   520 
   519 
   521     if ( iFaxSession )
   520     if ( iFaxSession )
   522         {
   521         {
   523         iFaxSession->FxClose();
   522         iFaxSession->FxClose();
   524         iMmCall->DeleteFaxProgressChunk();
   523         iMmCall->DeleteFaxProgressChunk();
   560 // ---------------------------------------------------------------------------
   559 // ---------------------------------------------------------------------------
   561 //
   560 //
   562  TInt CMmFaxExt::GetFaxSettings(
   561  TInt CMmFaxExt::GetFaxSettings(
   563         RCall::TFaxSessionSettings* aSettings ) 
   562         RCall::TFaxSessionSettings* aSettings ) 
   564     {
   563     {
   565 TFLOGSTRING("TSY: CMmFaxExt::GetFaxSettings");
   564 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMFAXEXT_GETFAXSETTINGS_1, "TSY: CMmFaxExt::GetFaxSettings");
   566     *aSettings = iFaxSettings;
   565     *aSettings = iFaxSettings;
   567     return KErrNone;
   566     return KErrNone;
   568     }
   567     }
   569 
   568 
   570 // ---------------------------------------------------------------------------
   569 // ---------------------------------------------------------------------------
   574 // ---------------------------------------------------------------------------
   573 // ---------------------------------------------------------------------------
   575 //
   574 //
   576  TInt CMmFaxExt::SetFaxSettings(
   575  TInt CMmFaxExt::SetFaxSettings(
   577         const RCall::TFaxSessionSettings* aSettings ) // in: fax settings.
   576         const RCall::TFaxSessionSettings* aSettings ) // in: fax settings.
   578     {
   577     {
   579 TFLOGSTRING("TSY: CMmFaxExt::SetFaxSettings");
   578 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMFAXEXT_SETFAXSETTINGS_1, "TSY: CMmFaxExt::SetFaxSettings");
   580         iFaxSettings = *aSettings;
   579         iFaxSettings = *aSettings;
   581         return KErrNone;
   580         return KErrNone;
   582     }
   581     }
   583 
   582 
   584 // ---------------------------------------------------------------------------
   583 // ---------------------------------------------------------------------------
   598 // Returns:  None 
   597 // Returns:  None 
   599 // ---------------------------------------------------------------------------
   598 // ---------------------------------------------------------------------------
   600 //
   599 //
   601 void CMmFaxExt::DialCancel()
   600 void CMmFaxExt::DialCancel()
   602     {
   601     {
   603     TFLOGSTRING("TSY: CMmFaxExt::DialCancel");
   602     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMFAXEXT_DIALCANCEL_1, "TSY: CMmFaxExt::DialCancel");
   604     if ( iFax ) 
   603     if ( iFax ) 
   605         {
   604         {
   606         iFax->Terminate();
   605         iFax->Terminate();
   607         }
   606         }
   608     }
   607     }