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