examples/SFExamples/symbian_os_communications_programming_book_v2/chapter8/receivingmessages/CWeatherReportWatcher.h

00001 // 
00002 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
00003 // All rights reserved.
00004 // This component and the accompanying materials are made available
00005 // under the terms of the License "Eclipse Public License v1.0"
00006 // which accompanies this distribution, and is available
00007 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
00008 // 
00009 // Initial Contributors:
00010 // Nokia Corporation - initial contribution.
00011 // 
00012 // Contributors:
00013 // 
00014 // Description:
00015 // 
00016 
00017 #ifndef MWEATHERREPORTWATCHER_H
00018 #define MWEATHERREPORTWATCHER_H
00019 
00020 #include <e32base.h>
00021 #include <e32cons.h>
00022 #include <ES_SOCK.H>
00023 #include <f32file.h>
00024 
00025 class MWeatherReportObserver
00026         {
00027 public:
00028 
00029         enum TWeatherReport
00030                 {
00031                 ENone,
00032                 ESunny,
00033                 ECloudy,
00034                 ERainy
00035                 };
00036 
00037         virtual void NewWeatherReport(TWeatherReport aWeatherReport) = 0;
00038         };
00039 
00040 class CWeatherReportWatcher : public CActive
00041         {
00042 public:
00043 
00044         ~CWeatherReportWatcher();
00045 
00046         // Construct and start listening for weather reports
00047         static CWeatherReportWatcher* NewL(MWeatherReportObserver& aWeatherReportObserver, RFs& aFs);
00048         
00049         // CActive functions
00050         void DoCancel();
00051         void RunL();
00052 
00053 private:
00054         CWeatherReportWatcher(MWeatherReportObserver& aWeatherReportObserver, RFs& aFs);
00055         void ConstructL();
00056         void WaitForWeatherReportL();
00057 
00058 private:
00059         RSocketServ iSocketServer;
00060         RSocket iSmsSocket;
00061         MWeatherReportObserver& iWeatherReportObserver;
00062         RFs& iFs;
00063         TPckgBuf<TUint> iSbuf;
00064         
00065         enum TWeatherWatcherState
00066                 {
00067                 EWaitingForWeatherReport,
00068                 EAcknowledgingWeatherReport 
00069                 };
00070                 
00071         TWeatherWatcherState iState;
00072         };
00073 
00074 #endif
00075 

Generated by  doxygen 1.6.2