src/ext/amaretto/telephone/inc/telephone.h
changeset 0 ca70ae20a155
equal deleted inserted replaced
-1:000000000000 0:ca70ae20a155
       
     1 /**
       
     2  * ====================================================================
       
     3  * telephone.h
       
     4  *
       
     5  * Copyright (c) 2005 - 2007 Nokia Corporation
       
     6  *
       
     7  * Licensed under the Apache License, Version 2.0 (the "License");
       
     8  * you may not use this file except in compliance with the License.
       
     9  * You may obtain a copy of the License at
       
    10  *
       
    11  *     http://www.apache.org/licenses/LICENSE-2.0
       
    12  *
       
    13  * Unless required by applicable law or agreed to in writing, software
       
    14  * distributed under the License is distributed on an "AS IS" BASIS,
       
    15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    16  * See the License for the specific language governing permissions and
       
    17  * limitations under the License.
       
    18  * ====================================================================
       
    19  */
       
    20 #include "Python.h"
       
    21 #include "symbian_python_ext_util.h"
       
    22 #include <e32std.h>
       
    23 
       
    24 #ifndef EKA2 
       
    25 #include <etel.h>
       
    26 _LIT(KTsyName,"phonetsy.tsy");
       
    27 #else
       
    28 #include <Etel3rdParty.h>
       
    29 #endif /* EKA2 */
       
    30 
       
    31 #define MaxTelephoneNumberLength 30
       
    32 
       
    33 #ifdef EKA2
       
    34 class TPyPhoneCallBack
       
    35   {
       
    36   public:
       
    37     TInt IncomingCall(TInt aStatus, TDesC& aNumber);
       
    38   public:
       
    39     PyObject* iCb; // Not owned.
       
    40   };
       
    41 #endif
       
    42 
       
    43 //Safe to use also from emulator.
       
    44 #ifndef EKA2
       
    45 class CPhoneCall : public CActive
       
    46 #else
       
    47 NONSHARABLE_CLASS (CPhoneCall) : public CActive
       
    48 #endif
       
    49   {
       
    50 public:
       
    51   static CPhoneCall* NewL();
       
    52   static CPhoneCall* NewLC();
       
    53   ~CPhoneCall();
       
    54 public: 
       
    55   CPhoneCall();
       
    56   void ConstructL();
       
    57   
       
    58   TInt Initialise();
       
    59   TInt UnInitialise();
       
    60   TInt Dial();
       
    61   void SetNumber(TDes& aNumber);
       
    62   TInt HangUp();
       
    63 #ifdef EKA2
       
    64   TInt Answer();
       
    65   void SetIncomingCallBack(TPyPhoneCallBack &aCb);
       
    66 #endif
       
    67   /*
       
    68   ENotCalling The initial (un-initialised) state
       
    69   EInitialised After Initialise() call, ready to Dial()
       
    70   ECalling A dial request has been issued
       
    71   ECallInProgress A call is ongoing
       
    72   */
       
    73 	enum TCallState 
       
    74 	  {
       
    75  #ifdef EKA2
       
    76     EHangingUp,
       
    77  #endif /* EKA2 */
       
    78 		ENotCalling,
       
    79 		EInitialised,
       
    80     ECalling,
       
    81     ECallInProgress
       
    82 	  };  
       
    83 	//These are returned to avoid ETel server panics:
       
    84 	enum TPhoneCallErrors
       
    85 	  {
       
    86 		ENumberNotSet = 0x7D0,
       
    87 		ENotInitialised,
       
    88 		ENotCallInProgress,
       
    89 		EInitialiseCalledAlready,
       
    90 		EAlreadyCalling,
       
    91 	  };  
       
    92 public: //from CActive:
       
    93   void RunL();
       
    94   void DoCancel();
       
    95 private:
       
    96 #ifndef EKA2
       
    97   RTelServer iServer;
       
    98   RTelServer::TPhoneInfo iInfo;
       
    99   RPhone iPhone;
       
   100   RPhone::TLineInfo iLineInfo;
       
   101   RLine iLine;
       
   102   TBuf<100> iNewCallName;
       
   103   RCall iCall;
       
   104 #else
       
   105   CTelephony* iTelephony;
       
   106   CTelephony::TCallId iCallId;
       
   107   CTelephony::TCallStatusV1Pckg iCallStatusV1Pckg;
       
   108   CTelephony::TCallStatusV1 iCallStatusV1;
       
   109 
       
   110   TPyPhoneCallBack iCallMe;
       
   111   TBool iCallBackSet;  
       
   112   TBool iWaitingForCall;
       
   113   TBool iAnswering;
       
   114 #endif /* EKA2 */
       
   115   TCallState iCallState;
       
   116   TBuf<MaxTelephoneNumberLength> iNumber;
       
   117   TBool iNumberSet;
       
   118   };
       
   119 
       
   120 //////////////TYPE DEFINITION
       
   121 
       
   122 #define PHO_type ((PyTypeObject*)SPyGetGlobalString("PHOType"))
       
   123 
       
   124 struct PHO_object {
       
   125   PyObject_VAR_HEAD
       
   126   CPhoneCall* phone;
       
   127 #ifdef EKA2
       
   128   TPyPhoneCallBack myCallBack;
       
   129   TBool callBackSet;
       
   130 #endif
       
   131 };