×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    13

    Application-autostart,run in background,rename file

    I want to make an application with the following features:
    1. autostart when the phone is turned on and runs in the background.
    2. checks all the time to see if *.txt files are present in a specified directory.
    3. if a *.txt file is detected in that folder then it should rename it, preferably using something to identify the phone.

    I am using Carbide.c++ Express 1.1. Actually I would be using it once I figure out how to start. The phone is a N70(S60 2nd).

    From what I figured until now(searching the forum and looking trough the SDK help and my problems:

    1. To autostart I need to set a [UID].rss file. Since my application will be installed on the memory card(is there any reason not to put it in there?) I don´t know where to put this rss file. In this state of development I believe that the application will be a sis file and not a dll. Is there any problem?(btw. the link that is usually provided for the autostart problem doesn´t have the source codes anymore.

    2. From what I saw I should use the RFs::NotifyChange(...) to check if a *.txt file was created in that folder. Since another application is putting the files there from time to time which TNotifyType should I use: ENotifyFile, ENotifyWrite or ENotifyAll? I see that it is of void type, so how do I know if a file have been created?

    3. Here I should use the RFs::Rename(...) and to set a unique identifier for the files that would identify them once they are on the PC I should use the CTelephony::GetPhoneId().

    4. Is there a problem if I don´t close the application when the phone powers off?

    I would apreciate any code snipets for the above problems(questions).
    Thanks.

  2. #2
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,355

    Re: Application-autostart,run in background,rename file

    Hi Marius,

    1) The solutions is valid only for S60 3rd Edition. For a S60 2nd Edition compatible solution loook for the Autostart API plugin on symbian.com
    2) ENotifyFile should be ok. The call is asynchronous so you need to wrapp the call in an active object and "wait" for it to complete.
    3) CTelephony might not work on S60 2nd Edition FP3 but you can try
    Code:
    TPlpVariantMachineId imei;
    PlpVariant::GetMachineIdL(imei);
    4) No

  3. #3
    Registered User
    Join Date
    Dec 2006
    Posts
    13

    Re: Application-autostart,run in background,rename file

    Hi ltomuta
    Thanks for the reply.

    Quote Originally Posted by ltomuta
    2) ENotifyFile should be ok. The call is asynchronous so you need to wrapp the call in an active object and "wait" for it to complete.
    I don´t know if I understand this. Can you give me a code snipet?
    Thanks.

  4. #4
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,355

    Re: Application-autostart,run in background,rename file

    Take this with a pinch of salt since I'm writing the code on the forum directly from an N800 device without having access to the docs:

    Code:
    class CObiectActiv : public CActive
    {
    public:
            virtual ~CObiectActiv();
            static CObiectActiv* NewL();
            void Start();
    
    private:
            CObiectActiv();
            void ConstructL();
    
    private:
            void RunL();
            void DoCancel();
    
    private:
            RFs iFs;
    
    }
    Code:
    CObiectActiv::CObiectActiv() : CActive(EPriorityStandard)
    {
    }
    
    CObiectActiv::~CObiectActiv()
    {
            Cancel(); // calls DoCancel if a request is pending
            iFs.Close(); // close file server session
    }
    
    CObiectActiv::ConstructL()
    {
            User::LeaveIfError(iFs.Connect());
            CActiveScheduler::Add(this);
    }
    
    CObiectActiv* CObiectActiv::NewL()
    {
            CObiectActiv* self = new (ELeave) CObiectActiv();
            CleanupStack::PushL(self);
            self->ConstructL();
            CleanupStack::Pop();
            return self ;
    }
    
    void CObiectActiv::Start()
    {
            Cancel();
            iFs.NotifyChange(ENotifyFile, iStatus, KFolderToWatch);
            SetActive();
            // this method completes although the notification request is still pending
            // unless other processing in place this thread goes idle
    }
    
    // this method gets called once a file is created (or if error)
    void CObiectActiv::RunL()
    {
            User::LeaveIfError(iStatus.Int()); // handle error case in RunError method
            Start(); // issue new request
            HandleFiles(); //quickly handle the files
    }
    
    CObiectActiv::DoCancel()
    {
            iFs.NotifyChangeCancel(); // If I remember correctly this is the cancel method name
    }

  5. #5
    Registered User
    Join Date
    Dec 2006
    Posts
    13

    Re: Application-autostart,run in background,rename file

    Thanks a lot! One problem solved.

  6. #6
    Registered User
    Join Date
    Dec 2006
    Posts
    13

    Re: Application-autostart,run in background,rename file

    Others to come.

    I have the following code:

    CObiect.h
    Code:
    CDir* iFileList;
    CObiect.cpp
    Code:
    _LIT(KPath,"E:\\Text\\Texts");
    	if (iFileList)
    	{
    		delete iFileList;
    		iFileList = NULL;
    	}
    	TInt result = iFs.GetDir(KPath,KEntryAttNormal,ESortByName|EAscending,iFileList);
    	if (result == KErrNone)
    	{
    		TInt fileCount = FileCount();
    		TInt index = 0;
                    /* here the problem starts*/
    		TBufC file;
               
    		for(index=0;index < fileCount; index++)
    		{
    			file = iFileList->operator[](index).iName;
    			
    		}
    	}
    Now, what I am trying to do is to get the files from that folder and start checking if the file is a txt file or not. If it is I want to change it´s name to something like IMEI+present_file_name .

    And I have problems with the code for the IMEI as I can´t find those variables types.

  7. #7
    Registered User
    Join Date
    Dec 2006
    Posts
    13

    Re: Application-autostart,run in background,rename file

    I´ve droped the IMEI feature. Now I´m running in circles because I can´t find out how to use the RFs::Rename(...) with the variable file(TBuf8<50> file).
    What I managed so far is to do this:
    Code:
    _LIT(KoldPath,"E:\\Images\Textos\\2002.txt");
    _LIT(KnewPath,"E:\\Images\\Textos\\2002.jpg");
     iRf.Replace(KoldPath,KnewPath);
    but I have no idea how to construct those strings from TBuf8.

  8. #8
    Registered User
    Join Date
    Dec 2006
    Posts
    13

    Re: Application-autostart,run in background,rename file

    Solved! I should have used instead TBuf no TBuf8 because TBuf can be converted to TDes.

  9. #9
    Registered User
    Join Date
    Dec 2006
    Posts
    13

    Re: Application-autostart,run in background,rename file

    I´ve installed the Start-On-Boot API provided by symbian but it doesn´t seem to work(most probably I´m using it wrong).

    I´ve put the folowing code in TUid CHelloApp::AppDllUid() const and after that in EXPORT_C CApaApplication* NewApplication() but it doesn´t register the application.
    Code:
    RServiceStartOnBoot marius;
    marius.CreateL();
    _LIT(KPath,"E:\\System\\Apps\\Hello\\Hello.app");
    marius.AddServiceL(KPath);
    marius.Close();
    So, where should I put this code or/and how should I change it?

    Thanks.

Similar Threads

  1. Replies: 50
    Last Post: 2012-09-14, 07:53
  2. [announce] PyUIQ. Python for UIQ 2.1 and 3.x
    By OscarBernabeu in forum Symbian
    Replies: 35
    Last Post: 2008-01-17, 09:12
  3. Pkg file for an application using a DLL?
    By araghava in forum Symbian
    Replies: 4
    Last Post: 2006-09-22, 05:58
  4. Replies: 2
    Last Post: 2002-12-03, 00:49

Posting Permissions

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