
Originally Posted by
kiran10182
Hi,
Ok.
If so then do following things:
- Open this example from: C:\Symbian\8.0a\S60_2nd_FP2\Series60Ex\smssend
- Copy CSmsHandler.h and CSmsHandler.cpp from smssend example.
- Paste them accordingly in your "HelloWorld" example in respected folders. (inc and src)
- More on next steps. First of all finish with these.
Kiran.
Thanks to your sources, I was eventually able to build my own.
It compiles fine on emulator, but it does not on real device, due to "uninitialised data" which let think to some static data around the source.... but WHERE? How did I declare static data? I just declared some variables in a "standard" manner.
This is my full .h source:
Code:
/*
============================================================================
Name : SMSParser2Application.h
Author : Luca Cassioli
Copyright : Your copyright notice
Description : Declares all classes
============================================================================
*/
#ifndef __SMSPARSER2_H
#define __SMSPARSER2_H
#include <coeccntx.h>
#include <eikenv.h>
#include <eikappui.h>
#include <eikapp.h>
#include <eikdoc.h>
#include <eikmenup.h>
#include <eikon.hrh>
#include <SMSParser2.rsg>
#include "SMSParser2.hrh"
#include <msvapi.h> // CMsvSession
#include <mtclreg.h> // CClientMtmRegistry
#include <SMSCLNT.h> // CSmsClientMtm
#include <smut.h> // KUidMsgTypeSMS
#include <msvstd.h> // TMsvEntry, CMsvEntrySelection
////////////////////////////////////////////////////////////////////////
//
// CSMSParser2Application
//
////////////////////////////////////////////////////////////////////////
class CSMSParser2Application : public CEikApplication
{
private:
// Inherited from class CApaApplication
CApaDocument* CreateDocumentL();
TUid AppDllUid() const;
};
////////////////////////////////////////////////////////////////////////
//
// CSMSParser2AppView
//
////////////////////////////////////////////////////////////////////////
class CSMSParser2AppView : public CCoeControl
{
public:
static CSMSParser2AppView* NewL(const TRect& aRect);
CSMSParser2AppView();
~CSMSParser2AppView();
void ConstructL(const TRect& aRect);
private:
// Inherited from CCoeControl
void Draw(const TRect& /*aRect*/) const;
private:
HBufC* iSMSParser2Text;
};
////////////////////////////////////////////////////////////////////////
//
// CSMSParser2AppUi
//
////////////////////////////////////////////////////////////////////////
class CSMSParser2AppUi : public CEikAppUi, public MMsvSessionObserver
{
public:
void ConstructL();
~CSMSParser2AppUi();
private:
// Inherirted from class CEikAppUi
void HandleCommandL(TInt aCommand);
private:
CMsvSession* iSession;
CClientMtmRegistry* iMtmReg;
CSmsClientMtm* iSmsMtm;
CSmsClientMtm* smsMtm;
TMsvEntry msvEntry;
CMsvEntrySelection* entries;
TMsvId ServiceId;
void HandleSessionEventL( TMsvSessionEvent aEvent, TAny* aArg1,
TAny* aArg2, TAny* aArg3 );
#if defined(_DEBUG)
/* Only used in this application to add a Close item in Debug mode */
void DynInitMenuPaneL(TInt aMenuId, CEikMenuPane* aMenuPane);
#endif
private:
CCoeControl* iAppView;
};
////////////////////////////////////////////////////////////////////////
//
// CSMSParser2Document
//
////////////////////////////////////////////////////////////////////////
class CSMSParser2Document : public CEikDocument
{
public:
static CSMSParser2Document* NewL(CEikApplication& aApp);
CSMSParser2Document(CEikApplication& aApp);
void ConstructL();
private:
// Inherited from CEikDocument
CEikAppUi* CreateAppUiL();
};
#endif
And this is the relevant .cpp:
Code:
/*
============================================================================
Name : SMSParser2AppUi.cpp
Author : Luca Cassioli
Copyright : Your copyright notice
Description : CSMSParser2AppUi implementation
============================================================================
*/
// To enable the dynamic loading of the menu with a Close command in the UDEB version
#include <eikmenub.h>
#include <msvapi.h> // CMsvSession
#include <mtclreg.h> // CClientMtmRegistry
#include <SMSCLNT.h> // CSmsClientMtm
#include <smut.h> // KUidMsgTypeSMS
#include <msvstd.h> // TMsvEntry, CMsvEntrySelection
#include <e32cons.h> // Per creare la console su cui stampare i risultati per il ***DEBUG***
//CConsoleBase* consoleFM; //La console
#include "SMSParser2Application.h"
// The second phase constructor of the application UI class.
// The application UI creates and owns the one and only view.
//
int numMessages;
void CSMSParser2AppUi::ConstructL()
{
// BaseConstructL() completes the UI framework's
// construction of the App UI.
BaseConstructL();
// Create the single application view in which to
// draw the text message, passing into it
// the rectangle available to it.
}
// The app Ui owns the two views and is.
// therefore, responsible for destroying them
//
CSMSParser2AppUi::~CSMSParser2AppUi()
{
delete iAppView;
}
// Called by the UI framework when a command has been issued.
// In this example, a command can originate through a
// hot-key press or by selection of a menu item.
// The command Ids are defined in the .hrh file
// and are 'connected' to the hot-key and menu item in the
// resource file.
// Note that the EEikCmdExit is defined by the UI
// framework and is pulled in by including eikon.hrh
//
void CSMSParser2AppUi::HandleCommandL(TInt aCommand)
{
long current;
// Crea console per mostrare risultati per ***DEBUG***:
// consoleFM=Console::NewL(_L("Console FM"),TSize(KConsFullScreen,KConsFullScreen)); // crea console
switch (aCommand)
{
// Just issue simple info messages to show that
// the menu items have been selected
case ESMSParser2Item0:
// iEikonEnv->InfoMsg(R_TEXT_ITEM0);
iAppView = CSMSParser2AppView::NewL(ClientRect());
iSession = CMsvSession::OpenSyncL(*this); //#include msvapi.h //msgs.lib
iMtmReg = CClientMtmRegistry::NewL(*iSession); //#include mtclreg.h // msgs.lib
iSmsMtm = static_cast<CSmsClientMtm*>(iMtmReg->NewMtmL(KUidMsgTypeSMS)); //#include SMSCLNT.h //smcm.lib (KUidMsgTypeSMS in smut.h (undocumented!))
//// consoleFM->Printf(_L("Connecting to message registry..."));
//iMtmReg = CClientMtmRegistry::NewL(*iSession); //#include mtclreg.h // msgs.lib
//// consoleFM->Printf(_L("Connected..."));
//// consoleFM->Printf(_L("Connecting to SMS MTM..."));
//iSmsMtm = static_cast<CSmsClientMtm*>(iMtmReg->NewMtmL(KUidMsgTypeSMS)); //#include SMSCLNT.h //smcm.lib (KUidMsgTypeSMS in smut.h (undocumented!))
// consoleFM->Printf(_L("Connected...\n"));
//CSmsClientMtm* smsMtm = pView->pMsgHandler->iSmsMtm; //#include SMSCLNT.h //smcm.lib
smsMtm = iSmsMtm; //#include SMSCLNT.h //smcm.lib
// consoleFM->Printf(_L("Accessing outbox...\n"));
smsMtm->SwitchCurrentEntryL(KMsvGlobalOutBoxIndexEntryId);
// consoleFM->Printf(_L("Connected.\n"));
// consoleFM->Printf(_L("Collecting SMS in outbox...\n"));
entries = smsMtm->Entry().ChildrenWithMtmL(KUidMsgTypeSMS);
// consoleFM->Printf(_L("CoLLected...\n"));
CleanupStack::PushL(entries);
// consoleFM->Printf(_L("Looking for errors in sent messages...\n"));
numMessages = entries->Count();
while(numMessages > 0 )
{
current = (*entries)[--numMessages];
smsMtm->SwitchCurrentEntryL(current);
smsMtm->Entry().Entry();
iSession->GetEntry(current,ServiceId, msvEntry);
// consoleFM->Printf(_L("Error code for this message: %d"),msvEntry.iError);
if (msvEntry.iError != 0 )
{
// DO SOMETHING
// consoleFM->Printf(_L("Messaggio non inviato!"));
}
}
// consoleFM->Printf(_L("Checkup complete, press any key."));
// consoleFM->Getch();
//delete consoleFM; // chiude console
break;
case ESMSParser2Item1:
// iEikonEnv->InfoMsg(R_TEXT_ITEM1);
break;
case ESMSParser2Item2:
// iEikonEnv->InfoMsg(R_TEXT_ITEM2);
break;
// Exit the application. The call is
// implemented by the UI framework.
case EEikCmdExit:
Exit();
break;
}
}
// This is a way to dynamically initialize the menu.
// If it is the debug version, the menu should contain a Close command.
// In the release version, there should be no Close command.
#if defined(_DEBUG)
void CSMSParser2AppUi::DynInitMenuPaneL(TInt aMenuId, CEikMenuPane* aMenuPane)
{
if(aMenuId == R_FIRST_MENU)
{
CEikMenuPaneItem::SData itemData;
TBuf<16> closeCommandText;
iEikonEnv->ReadResource(closeCommandText, R_CLOSE_COMMAND);
itemData.iText=closeCommandText;
itemData.iCommandId=EEikCmdExit;
itemData.iFlags=0;
itemData.iCascadeId=0;
aMenuPane->AddMenuItemL(itemData);
}
}
#endif
// -----------------------------------------------------------------------------
// CSmsHandler::HandleSessionEventL()
// Handles notifications of events from the Message Server.
// -----------------------------------------------------------------------------
//
void CSMSParser2AppUi::HandleSessionEventL( TMsvSessionEvent aEvent,
TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/)
{
}
BTW, I remember I found, years ago, a site where you could share sources with people for collabrative development in real-time ... Not sourceforge, just a "temporary source hosting"... Any idea about the link?