bluetooth/btcomm/tsrc/tcsy.h
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef TCSY_H
       
    17 #define TCSY_H
       
    18 
       
    19 // forward declarations
       
    20 #include <e32test.h>
       
    21 #include <e32math.h>
       
    22 #include <es_sock.h>
       
    23 #include <f32file.h>
       
    24 #include <bt_sock.h>
       
    25 #include <c32comm.h>
       
    26 #include <btmanclient.h>
       
    27 #include <btextnotifiers.h>
       
    28 
       
    29 #include <bluetooth/hci/hcierrors.h>
       
    30 
       
    31 class CActiveConsole;
       
    32 class CActiveRootConsole;
       
    33 class CActiveCommConsole;
       
    34 
       
    35 class CCSY;
       
    36 class CAutoJimmier;
       
    37 
       
    38 _LIT(KDateFormatter,"%-B%:0%J%:1%T%:2%S%.%*C4%:3%+B");
       
    39 const TInt KAutoRemoveTime = 6000000;
       
    40 const TInt KAutoStartTime = 3000000;
       
    41 
       
    42 NONSHARABLE_CLASS(CCSYApp) : public CBase
       
    43 	{
       
    44 	public:
       
    45 		static CCSYApp* NewL(CConsoleBase& aConsole, TBool aAutoAuto = ETrue);
       
    46 		void NewCSYL(TBool aStartReadingOnOpen=EFalse);
       
    47 		void DeleteAllConnections();
       
    48 		void DeleteConnection(const CCSY* aComm);
       
    49 		void AutoMode();
       
    50 		void ReStartAutoMode();
       
    51 		void SingleCSYL();
       
    52 		void FetchWebPageL();
       
    53 		void C32UHeapMark();
       
    54 		void C32UHeapMarkEnd();
       
    55 		void StartExclusiveSessionL();
       
    56 		void StopExclusiveSession();
       
    57 
       
    58 		void StartL();
       
    59 		void Stop();
       
    60 		~CCSYApp();
       
    61 
       
    62 	private:
       
    63 		CCSYApp(CConsoleBase& aConsole);
       
    64 		void ConstructL(CConsoleBase& aConsole, TBool aAutoAuto = ETrue);
       
    65 
       
    66 	private:
       
    67 		CActiveRootConsole*	iActiveRootConsole;
       
    68 		CConsoleBase& iConsole;
       
    69 
       
    70 		RPointerArray<CCSY> iConnections;
       
    71 		RCommServ			iCommServer;
       
    72 		RSocketServ			iExclusiveSession;
       
    73 		CAutoJimmier*		iJimmier;
       
    74 	};
       
    75 
       
    76 NONSHARABLE_CLASS(CActiveConsoleBase) : public CActive
       
    77 	{
       
    78 	public:
       
    79 		void DoCancel();
       
    80 		virtual void DrawMenu() = 0;
       
    81 		virtual void DrawCursor();
       
    82 		void TimePrint();
       
    83 		~CActiveConsoleBase();
       
    84 
       
    85 	protected:
       
    86 		CActiveConsoleBase(CConsoleBase& aConsole);
       
    87 		void RequestKey();
       
    88 		TInt RunError(TInt aError);
       
    89 
       
    90 	protected:
       
    91 		CConsoleBase&		iConsole;
       
    92 		TTime				iTime;
       
    93 	};
       
    94 
       
    95 NONSHARABLE_CLASS(CActiveCommConsole) : public CActiveConsoleBase
       
    96 	{
       
    97 	public:
       
    98 		static CActiveCommConsole* NewL(CConsoleBase& aConsole, CCSY& aCSY);
       
    99 		virtual void DrawMenu();
       
   100 	private:
       
   101 		void RunL();
       
   102 		CActiveCommConsole(CConsoleBase& aConsole, CCSY& aApp);
       
   103 	private:
       
   104 		CCSY&			iComm;
       
   105 
       
   106 	};
       
   107 
       
   108 NONSHARABLE_CLASS(CActiveRootConsole) : public CActiveConsoleBase
       
   109 	{
       
   110 	public:
       
   111 		static CActiveRootConsole* NewL(CConsoleBase& aConsole, CCSYApp& aApp);
       
   112 		virtual void DrawMenu();
       
   113 	private:
       
   114 		void RunL();
       
   115 		CActiveRootConsole(CConsoleBase& aConsole, CCSYApp& aApp);
       
   116 	private:
       
   117 		CCSYApp&		iApp;
       
   118 	};
       
   119 
       
   120 NONSHARABLE_CLASS(CCSY) : public CActive
       
   121 	{
       
   122 	// abstract class for derivation - deriveees implement RunL and Start
       
   123 	public:
       
   124 		~CCSY();
       
   125 		static CCSY* NewL(CConsoleBase& aConsole, CCSYApp& aApp, RCommServ& aCommServer);
       
   126 		void Read();
       
   127 		void Close();
       
   128 		void Destroy();
       
   129 		static CConsoleBase* AutoSizeNewL(const TDesC& aTitle, TSize aSize);
       
   130 
       
   131 	protected:
       
   132 		CCSY(CConsoleBase& aConsole, CCSYApp& aApp, RCommServ& aCommServer);
       
   133 		void ConstructL();
       
   134 		void DoCancel();
       
   135 		void RunL();
       
   136 
       
   137 	protected:
       
   138 		CConsoleBase&		iRootConsole;	// may bin
       
   139 		CConsoleBase*		iCommConsole;
       
   140 		CCSYApp&			iApp;
       
   141 		RCommServ&			iCommServer;
       
   142 		RComm				iComm;
       
   143 		CActiveCommConsole*	iActiveCommConsole;
       
   144 		TBuf8<10>			iBuffer; // not interested in large data at present
       
   145 
       
   146 	private:
       
   147 		TInt RunError(TInt aError);
       
   148 
       
   149 	private:
       
   150 		static TInt			iCommInstance;
       
   151 		enum TCommStates
       
   152 			{
       
   153 			EReading,
       
   154 			EWriting,
       
   155 			};
       
   156 		TCommStates			iCommState;
       
   157 
       
   158 	};
       
   159 
       
   160 
       
   161 NONSHARABLE_CLASS(CAutoJimmier) : public CTimer
       
   162 	{
       
   163 	public:
       
   164 		static CAutoJimmier* NewL(CConsoleBase& aConsole, CCSYApp& aApp);
       
   165 		void StartTimer();
       
   166 
       
   167 	private:
       
   168 		CAutoJimmier(CConsoleBase& aConsole, CCSYApp& aApp);
       
   169 		void ConstructL();
       
   170 		void RunL();
       
   171 		TInt RunError(TInt aError);
       
   172 
       
   173 	private:
       
   174 		CConsoleBase&		iConsole;
       
   175 		CCSYApp&			iApp;
       
   176 		TInt64				iSeed;
       
   177 		TBool				iRemove;
       
   178 	};
       
   179 
       
   180 
       
   181 #endif // TCSY_H