examples/SFExamples/NotifierExample/Notifier/src/Notifier1.cpp

00001 // Notifier1.cpp
00002 //
00003 // Copyright (c) 2007 Symbian Software Ltd.  All rights reserved.
00004 //
00005 
00006 #include "Notifier1.h"
00007 #include <Notifier1Uids.h> //Exported header containing UIDs for launching notifiers in this DLL
00008 #include "Notifier1.hrh"
00009 #include <eikenv.h>
00010 #include <bautils.h>
00011 #include <Notifier1Dialog.rsg>
00012 #include <ImplementationProxy.h>        // For the ECom entry point definitions
00013 
00014 #include <eikedwin.h>  //for edwin
00015 
00016 const TUid KScreenOutput = { 0x10009D48 };
00017 
00018 CNotifier1* CNotifier1::NewLC()
00019         {
00020         CNotifier1* self = new(ELeave) CNotifier1();
00021         CleanupStack::PushL(self);
00022         self->ConstructL();
00023         return self;
00024         }
00025         
00026 CNotifier1::~CNotifier1()
00027         {
00028         }
00029         
00030 CNotifier1::CNotifier1()
00031         {
00032         }
00033         
00034 void CNotifier1::ConstructL()
00035         {
00036     #ifdef __EPOC32__
00037                 _LIT(KResourceFile, "\\resource\\apps\\Notifier1Dialog.rsc");
00038     #else
00039                 _LIT(KResourceFile, "z:\\resource\\apps\\Notifier1Dialog.rsc"); 
00040         #endif
00041         TFileName resourceFileName(KResourceFile);
00042         BaflUtils::NearestLanguageFile(iEikonEnv->FsSession(), resourceFileName);
00043         TInt offset = iEikonEnv->AddResourceFileL(resourceFileName);
00044         TRAPD(err,ConstructSleepingAlertDialogL(R_NOTIFIER1));
00045            
00046         iEikonEnv->DeleteResourceFile(offset);
00047         User::LeaveIfError(err);
00048         }
00049 
00050 void CNotifier1::Release()
00051         {
00052         delete this;
00053         }
00054         
00055 CNotifier1::TNotifierInfo CNotifier1::RegisterL()
00056         {
00057         iInfo.iUid=KNotifier1Uid;
00058         iInfo.iChannel=KScreenOutput;
00059         iInfo.iPriority=ENotifierPriorityHigh;
00060         return iInfo;
00061         }
00062         
00063 CNotifier1::TNotifierInfo CNotifier1::Info() const
00064         {
00065         return iInfo;
00066         }
00067         
00068 void CNotifier1::StartL(const TDesC8& /*aBuffer*/, TInt /*aReplySlot*/, const RMessagePtr2& aMessage)
00069         {
00070         aMessage.Complete(KErrNotSupported);
00071         }
00072         
00073 
00074 TPtrC8 CNotifier1::StartL(const TDesC8& aBuffer)
00075         {
00076         if (!IsVisible())
00077                 {
00078                 CEikEdwin* editor1 = (CEikEdwin *) Control(ENotifier1ControlEditor);
00079                 TInt length=aBuffer.Length();
00080                 HBufC* theBuffer=HBufC::NewLC(length);
00081                 TPtr theBufferPtr = theBuffer->Des();
00082                 theBufferPtr.Copy(aBuffer);
00083                 editor1->SetTextL(theBuffer);
00084                 CleanupStack::PopAndDestroy(theBuffer);
00085                 RouseSleepingDialog();
00086                 }
00087         return KNullDesC8();
00088         }
00089         
00090 void CNotifier1::Cancel()
00091         {
00092         ExitSleepingDialog();
00093         }
00094         
00095 TPtrC8 CNotifier1::UpdateL(const TDesC8& aBuffer)
00096         {
00097         CEikEdwin* editor1 = (CEikEdwin *) Control(ENotifier1ControlEditor);
00098         TInt length=aBuffer.Length();
00099         HBufC* theBuffer=HBufC::NewLC(length);
00100         TPtr theBufferPtr = theBuffer->Des();
00101         theBufferPtr.Copy(aBuffer);
00102         editor1->SetTextL(theBuffer);
00103         CleanupStack::PopAndDestroy(theBuffer);
00104         DrawNow();
00105         return KNullDesC8();
00106         }
00107                 
00108 void CNotifier1::UpdateL(const TDesC8& /*aBuffer*/, TInt /*aReplySlot*/, const RMessagePtr2& aMessage)
00109         {
00110         aMessage.Complete(KErrNotSupported);
00111         }
00112 
00113 void CreateNotifiersL(CArrayPtrFlat<MEikSrvNotifierBase2>& aNotifiers)
00114         {
00115         CNotifier1* notifier1 = CNotifier1::NewLC();
00116         aNotifiers.AppendL(notifier1);
00117         CleanupStack::Pop(notifier1);
00118         }
00119 
00120 CArrayPtr<MEikSrvNotifierBase2>* NotifierArray()
00121         {
00122         CArrayPtrFlat<MEikSrvNotifierBase2>* notifiers = new CArrayPtrFlat<MEikSrvNotifierBase2>(5);
00123         if (notifiers)
00124                 {
00125                 TRAPD(err, CreateNotifiersL(*notifiers));
00126                 if (err)
00127                         {
00128                         TInt count = notifiers->Count();
00129                         while (count--)
00130                                 {
00131                                 (*notifiers)[count]->Release();
00132                                 }
00133                         delete notifiers;
00134                         notifiers = NULL;
00135                         }
00136                 }
00137         return notifiers;
00138         }
00139 
00140 
00141 TInt CNotifier1::NotifierCapabilites()
00142         {
00143         return EScreenDeviceChangeSupported;
00144 //Symbian OS v9 supports multiple screen orientations/modes. If a single mode is guaranteed you can return ENoSpecialCapabilities, but this may fail on the Emulator.
00145         }
00146 
00147 // ECom plugin entry point
00148 
00149 const TImplementationProxy ImplementationTable[] =
00150         {
00151     IMPLEMENTATION_PROXY_ENTRY(0x102826DB, NotifierArray)
00152         };
00153 
00154 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
00155         {
00156         aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
00157         return ImplementationTable;
00158         }

Generated by  doxygen 1.6.2