×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    How can I add a function to my project?

    Looks like adding just a single function to an existing c++ project is not as simple as I thought....
    How can I add this function to the default Helloworld project of any SDK?

    Code:
    void CSMSParserAppUi::doit()
    {
    CConsoleBase* consoleFM; 		
    
    	CMsvSession* iSession = CMsvSession::OpenSyncL(*this); //#include msvapi.h //msgs.lib 
    	CClientMtmRegistry* iMtmReg = CClientMtmRegistry::NewL(*iSession); //#include mtclreg.h // msgs.lib
    	CSmsClientMtm* iSmsMtm = static_cast<CSmsClientMtm*>(iMtmReg->NewMtmL(KUidMsgTypeSMS)); //#include SMSCLNT.h //smcm.lib
    	
    	TMsvId ServiceId;
    	TMsvEntry msvEntry; //#include msvstd.h  // msgs.lib 
    	//CSmsClientMtm* smsMtm = pView->pMsgHandler->iSmsMtm; //#include SMSCLNT.h //smcm.lib
    	CSmsClientMtm* smsMtm = iSmsMtm; //#include SMSCLNT.h //smcm.lib
    	CMsvEntrySelection* entries; // #include msvstd.h  // msgs.lib
    	smsMtm->SwitchCurrentEntryL(KMsvGlobalInBoxIndexEntryId); 
    	entries = smsMtm->Entry().ChildrenWithMtmL(KUidMsgTypeSMS);
    	CleanupStack::PushL(entries);
    	int numMessages = entries->Count();
    	long current;
    consoleFM->Printf(_L("Meesages found:%d") , numMessages);
    	
    	while(numMessages > 0 ) 
    	{
    	    current = (*entries)[--numMessages];
    	    smsMtm->SwitchCurrentEntryL(current); 
    	    smsMtm->Entry().Entry();
    	    iSession->GetEntry(current,ServiceId, msvEntry);
    _LIT(KDefaultSnapshot, "C:\\frodo.snap");	    
    RDebug::Print(KDefaultSnapshot);
    	    if (msvEntry.Unread() )
    	        {
    	        // DO SOMETHING
    	        }
    	}	
    }
    Errors:
    "C:\Symbian\UIQ_21\epoc32\include" -o src/SMSParserAppUi.o ../src/SMSParserAppUi.cpp
    ../src/SMSParserAppUi.cpp:100: no `void CSMSParserAppUi::doit()' member function declared in class `CSMSParserAppUi'
    ../src/SMSParserAppUi.cpp: In method `void CSMSParserAppUi::doit()':
    ../src/SMSParserAppUi.cpp:103: no matching function for call to `CMsvSession::OpenSyncL (CSMSParserAppUi &)'
    C:\\Symbian\\UIQ_21\\epoc32\\include\\MSVAPI.H:162: candidates are: CMsvSession::OpenSyncL(MMsvSessionObserver &)
    ../src/SMSParserAppUi.cpp:101: warning: `class CConsoleBase * consoleFM' might be used uninitialized in this function

  2. #2
    Registered User
    Join Date
    Jul 2005
    Location
    Bengaluru, India
    Posts
    747

    Re: How can I add a function to my project?

    Though I never worked in UIQ here are some observatins.

    Quote Originally Posted by cassioli
    ../src/SMSParserAppUi.cpp:101: warning: `class CConsoleBase * consoleFM' might be used uninitialized in this function
    I'm not understanding why you want a CConsoleBase on a application which is using the Frame work! It would be better going for some alerts.

    Quote Originally Posted by cassioli
    ...
    Errors:
    "C:\Symbian\UIQ_21\epoc32\include" -o src/SMSParserAppUi.o ../src/SMSParserAppUi.cpp
    ../src/SMSParserAppUi.cpp:100: no `void CSMSParserAppUi::doit()' member function declared in class `CSMSParserAppUi'
    Before defining a function in your CPP file you've to declare it in it's corresponding Header file.

    Quote Originally Posted by cassioli
    ../src/SMSParserAppUi.cpp: In method `void CSMSParserAppUi::doit()':
    ../src/SMSParserAppUi.cpp:103: no matching function for call to `CMsvSession::OpenSyncL (CSMSParserAppUi &)'
    C:\\Symbian\\UIQ_21\\epoc32\\include\\MSVAPI.H:162: candidates are: CMsvSession::OpenSyncL(MMsvSessionObserver &)
    If you want to use an API first check what the SDK Help says, check it's signature:

    Code:
    static IMPORT_C CMsvSession *OpenSyncL(MMsvSessionObserver &aObserver);
    Here you've to implement MMsvSessionObserver to your CSMSParserAppUi class and over-ride the necessary pure virtual functions. It's better you may go through some Example application before starting with your code.

  3. #3
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: How can I add a function to my project?

    Quote Originally Posted by vin2ktalks
    Though I never worked in UIQ here are some observatins.


    I'm not understanding why you want a CConsoleBase on a application which is using the Frame work! It would be better going for some alerts.
    It's just for debuggin purpose. An "old-fashion" debugging.


    Before defining a function in your CPP file you've to declare it in it's corresponding Header file.
    Thanks, that's what I wanted to know.

    If you want to use an API first check what the SDK Help says, check it's signature:

    Code:
    static IMPORT_C CMsvSession *OpenSyncL(MMsvSessionObserver &aObserver);
    I just copied this source from somewhere,I didn't write it myself.
    Here you've to implement MMsvSessionObserver to your CSMSParserAppUi class and over-ride the necessary pure virtual functions. It's better you may go through some Example application before starting with your code.
    The SMS example on forum nokia is too complex for my poor c++ knowledge. I wonder why such a complex source is needed to explain message handling: wouldn't be better some "tips" about what to add to the standard Helloworld example to obtain some SEPARATED features? I even "feedbacked" nokia about this.
    Rather than providing full sources made up of dozens of source files, it would be much better to explain how to extend Helloworld to obtain this or that feature (add this "include", add that library, add this line, change that param...)

  4. #4
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,347

    Smile Re: How can I add a function to my project?

    Hi,
    Quote Originally Posted by cassioli
    ...
    The SMS example on forum nokia is too complex for my poor c++ knowledge. I wonder why such a complex source is needed to explain message handling: wouldn't be better some "tips" about what to add to the standard Helloworld example to obtain some SEPARATED features? I even "feedbacked" nokia about this.
    Rather than providing full sources made up of dozens of source files, it would be much better to explain how to extend Helloworld to obtain this or that feature (add this "include", add that library, add this line, change that param...)
    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.

  5. #5
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: How can I add a function to my project?

    Quote 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.
    I don't want to download ANOTHER sdk (I guess it would mess up again my system: that happens every time I inistall a symbian sdk...).
    Besides, I'm currently in office, while my "development PC" is at home...
    ANyway, if you could send me those two files in the meantime, I could give them a look.
    I'll be at my development PC at 17.00 GMT.

  6. #6
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,347

    Smile Re: How can I add a function to my project?

    Ok.
    Send me a PM with your current SDK configuration. etc...

    I hope i will be helpful to you somehow.

    Kiran.

  7. #7
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: How can I add a function to my project?

    Quote 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?

  8. #8
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,347

    Smile Re: How can I add a function to my project?

    Hello cassioli,
    Quote Originally Posted by cassioli
    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.
    vin2ktalks has already suggested a link in other thread.
    Anyways refer to the following link:
    http://www.newlc.com/article.php3?id_article=529

    Kiran.

Similar Threads

  1. error LNK2019: unresolved external symbol ???
    By wgarnett in forum Symbian
    Replies: 3
    Last Post: 2009-09-28, 06:53
  2. C-code..unable to make sis
    By Symbian_Neil in forum Symbian
    Replies: 9
    Last Post: 2006-12-02, 07:55
  3. Replies: 0
    Last Post: 2006-08-09, 11:27
  4. Import\Export Project Problem in Carbide
    By mohsin.sohail in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 4
    Last Post: 2006-07-17, 20:20

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×