×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    18

    How to Adding custom menu items in MTM

    Hello,

    I want to add a custom menu item to the Options menu of the Messaging application.
    I tried to do it on the MTM example, and follow the instructions from http://wiki.forum.nokia.com/index.ph..._3rd_party_MTM

    But I'm quite confused. I don't understand how the constants like R_TEXTUD_NOT_SUPPORTED and R_TEXTUD_ONLY_MESSAGES are defined.
    somehow, it seems related to the definition of
    RESOURCE TBUF80 r_textud_only_messages {buf="This can only be done on local messages";}
    in the .rss file.

    For example, I want to create a new item.
    What I did is:
    1. Add the MTUD_FUNCTION
    MTUD_FUNCTION {
    functiontext="start OFINE";
    command=ETxtuCommandStartOFINE;
    flags=EMtudCommandTransferReceive; },
    2. define r_textud_start_ofine
    RESOURCE TBUF80 r_textud_start_ofine {buf="Start OFINE service";}
    3. Implementation of OperationSupportedL() in the UI Data MTM
    if(aOperationId == ETxtuCommandStartOFINE)
    aReasonResourceId=R_TEXTUD_START_OFINE;

    But it doesn't work. and I also cannot see the connection between R_TEXTUD_START_OFINE and MTUD_FUNCTION.

    Someone please help me.
    Thank you in advance.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: How to Adding custom menu items in MTM

    Though I have no experience with implementing MTM-s, and the referred Wiki page seems a bit confusing to me, here is what I would try:
    -check CBaseMtmUi
    -- search for menu, no hit
    -- search for resource, there will be GetResourceFileName, abstract method, seems to be important, and you have obviously already implemented it.
    -- no other ideas, perhaps CBaseMtmUi is not important from this point of view
    -check CBaseMtmUiData (I have just remembered from some readings, that such class actually exists)
    -- search for menu once more, there will be MtmSpecificFunctions and iCaption. The latter (iCaption) is something, you can try what happens if you set it, I do not know. The former (MtmSpecificFunctions) is not implemented by you, but it says it returns iMtmSpecificFunctions
    -- check what iMtmSpecificFunctions is. It says, it is filled by ReadFunctionsFromResourceFileL
    -- check what ReadFunctionsFromResourceFileL is. It says it is usually called by PopulateArraysL.
    -- check what PopulateArraysL is. It is an abstract method, so it probably already exists in your code. So this is the place where you can either call the previous method (ReadFunctionsFromResourceFileL), or just create a TMtmUiFunction, and append it to iMtmSpecificFunctions.
    -- since resources are involved, search for resource, a new method-hit will be GetResourceFileName (abstract, so probably already present in your code), and ReadFunctionsFromResourceFileL will be found once more.
    --- besides that there will be textual hits too, for example the first one says that aReasonResourceId in various methods simply identifies a string resource when something is not supported.

    #1 in your post is suspicious, since ReadFunctionsFromResourceFileL talks about array. So there should rather be RESOURCE ARRAY blabla, and some MTUD_FUNCTION members in it.
    #2 might be fine, however I do not know if TBUF80 is OK or not
    #3 can not compile since OperationSupportedL does not have aReasonResourceId.

    What should happen according to the quick-check of CBaseMtmUiData:
    - implement GetResourceFileName, return the correct file name
    - implement PopulateArraysL, invoke ReadFunctionsFromResourceFileL on it, or - which might be safer as a first try - simpli create a TMtmUiFunction, and append it to the iMtmSpecificFunctions array
    Then as a first try you can simply always return a resource id for a TBUF from OperationSupportedL, and EFalse from Can... methods (while setting aReasonResourceId to a TBUF resource)

    The related Wiki page seems to be bad, at least to me - though I have never tried MTM-s.

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    18

    Re: How to Adding custom menu items in MTM

    Quote Originally Posted by wizard_hu_ View Post
    - implement PopulateArraysL, invoke ReadFunctionsFromResourceFileL on it, or - which might be safer as a first try - simpli create a TMtmUiFunction, and append it to the iMtmSpecificFunctions array
    Then as a first try you can simply always return a resource id for a TBUF from OperationSupportedL, and EFalse from Can... methods (while setting aReasonResourceId to a TBUF resource)
    So what is your suggestion?
    Do you want me to create TMtmUiFunction manually and append it to iMtmSpecificFunctions?

    actually, after my first step, I have a MTUD_FUNCTION_ARRAY like:
    RESOURCE MTUD_FUNCTION_ARRAY r_textud_function_array
    {
    functions=
    {

    MTUD_FUNCTION
    {
    functiontext = "OFINE";
    command = KMtmUiMceSettings;
    flags = EMtudCommandTransferSend;
    },
    MTUD_FUNCTION {
    functiontext="Refresh service";
    command=ETxtuCommandRefreshMBox;
    flags=EMtudCommandTransferReceive;
    },

    MTUD_FUNCTION {
    functiontext="start OFINE";
    command=ETxtuCommandStartOFINE;
    flags=EMtudCommandTransferReceive;
    },

    MTUD_FUNCTION
    {
    functiontext = "Message command";
    command = ETxtuCommandMessage;
    flags = EMtudContextSpecific|EMtudAsynchronous|EMtudCommandTransferSend;
    }
    };
    }

    My question is,
    take "Refresh service" for example,
    what is the relation between R_TEXTUD_ONLY_REFRESH_SERVICES and r_textud_only_refresh_services. I can see the definition of R_TEXTUD_ONLY_REFRESH_SERVICES in C:\Symbian\9.2\S60_3rd_FP1\Epoc32\include\txti.RSG, but when OperationSupportedL() returns R_TEXTUD_ONLY_REFRESH_SERVICES, how does the system know which MTUD_FUNCTION should be used.

    I did almost the same thing for "start OFINE" as did for "Refresh service"(I copied the code for "Refresh service" and changed it), but "start OFINE" just doesn't display in the option menu as "Refresh service" does.
    I'm totally confused.

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: How to Adding custom menu items in MTM

    The array seems to be fine, try invoking ReadFunctionsFromResourceFileL from your PopulateArraysL, and see what happens.

Similar Threads

  1. MTM: custom menu items in Message list view
    By alphaMail in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2008-08-14, 13:37
  2. Does S60 Gallery support AIW to insert custom menu items?
    By JOM in forum Symbian Media (Closed)
    Replies: 6
    Last Post: 2008-06-12, 08:22
  3. adding menu item in Inbox using MTM
    By gpalvia in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2007-09-17, 14:00
  4. Adding Items to Custom ListBox at runtime
    By nickyc in forum Symbian User Interface
    Replies: 0
    Last Post: 2007-05-01, 14:15
  5. Adding items to menu gives "Program closed"
    By mozgido in forum Symbian
    Replies: 2
    Last Post: 2007-03-06, 17:59

Posting Permissions

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