Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
joelajean
Posts: 124
Registered: ‎01-25-2010
My Device: Z10, Dev Alpha B & Bold 9900
My Carrier: Bell
Accepted Solution

Invoking email with attachement - Broken with 10.2 ???

The following used to work fine on 10.1, but on 10.2, the invocation fails...

    attachedObjects: [  
        Invocation 
        {
            id: emailQuery
            query 
            {
                invokeActionId: "bb.action.SHARE"
                mimeType: "*"
                invokeTargetId: "sys.pim.uib.email.hybridcomposer"
            }
            onArmed: 
            {
                trigger("bb.action.SHARE");
            }
        }
    ]

    function shareFiles(s) 
    {
        console.debug("file://" + s)
        emailQuery.query.uri = "file://" + s;
        emailQuery.query.updateQuery();
    }

 
and returns in the console log...

 

file:///accounts/1000/shared/documents/mydatafile.csv
InvocationWrapper::onQueryFinished: no matching result from Menu Service for query
   mimeType="*"
   uri=QUrl("file:///accounts/1000/shared/documents/mydatafile.csv")
   data= ""
   metadata= QMap()
   perimeter= 0
   action= "bb.action.SHARE"
   target= "sys.pim.uib.email.hybridcomposer"
   invokerIncluded= false
InvocationPrivate::onQueryResolved: no result matching query, no armed signal sent. 

 
Any suggestions... Tried different approach by looking up different thread related to subject but so far no luck...

Please use plain text.
Developer
slashkyle
Posts: 814
Registered: ‎10-16-2012
My Device: Red Z10, Dev Alpha C
My Carrier: Telus

Re: Invoking email with attachement - Broken with 10.2 ???

[ Edited ]

This is confirmed to not be working in 10.2 (Thread)

 

I had issues about a year ago in 10.0 with it and switched to a c++ version that still works on the latest update

 

 *Assuming a context property is setup in this example it's cpp.

applicationUI.cpp

 

#include <bb/system/InvokeRequest>
#include <bb/system/InvokeManager>
#include <bb/PpsObject>

using namespace bb::system;

 

void ApplicationUI::email()
{
	InvokeRequest request;
	request.setAction("bb.action.COMPOSE");
	request.setMimeType("message/rfc822");
	QVariantMap data;
	data["to"] = (QVariantList() << "someone@somewhere.com");
	data["subject"] = "Message Title";
	QVariantMap moreData;
	moreData["data"] = data;
	bool ok;
	request.setData(bb::PpsObject::encode(moreData, &ok));
	InvokeManager manager;
	manager.invoke(request);
}

 

applicationUI.hpp

 

namespace bb
{
    namespace cascades
    {
        class Application;
        class LocaleHandler;
    }
    namespace system
    {
    	class InvokeManager;
    }
}

 

 

public:
    ApplicationUI(bb::cascades::Application *app);
    virtual ~ApplicationUI() { }
    
    Q_INVOKABLE void email();

 

 

.qml

 

Button {
   onClicked: {
     cpp.email();
  }
}

 

*i belive files can be attached if you add it into the QVariantMap data array, I think this should do the trick

data["attachment"] = "file:///path/to/my/item.txt";
Please use plain text.
Developer
greenmr
Posts: 874
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: Invoking email with attachement - Broken with 10.2 ???

This is because 10.2 broke the InvokeQuery class. You might want to look at the Invoker class I published here, which works fine under 10.2 and wraps any kind of invocation up in a neat little package which works from C++ or QML.

 


joelajean wrote:

The following used to work fine on 10.1, but on 10.2, the invocation fails...

    attachedObjects: [  
        Invocation 
        {
            id: emailQuery
            query 
            {
                invokeActionId: "bb.action.SHARE"
                mimeType: "*"
                invokeTargetId: "sys.pim.uib.email.hybridcomposer"
            }
            onArmed: 
            {
                trigger("bb.action.SHARE");
            }
        }
    ]

    function shareFiles(s) 
    {
        console.debug("file://" + s)
        emailQuery.query.uri = "file://" + s;
        emailQuery.query.updateQuery();
    }

 
and returns in the console log...

 

file:///accounts/1000/shared/documents/mydatafile.csv
InvocationWrapper::onQueryFinished: no matching result from Menu Service for query
   mimeType="*"
   uri=QUrl("file:///accounts/1000/shared/documents/mydatafile.csv")
   data= ""
   metadata= QMap()
   perimeter= 0
   action= "bb.action.SHARE"
   target= "sys.pim.uib.email.hybridcomposer"
   invokerIncluded= false
InvocationPrivate::onQueryResolved: no result matching query, no armed signal sent. 

 
Any suggestions... Tried different approach by looking up different thread related to subject but so far no luck...






Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.
Please use plain text.
Developer
joelajean
Posts: 124
Registered: ‎01-25-2010
My Device: Z10, Dev Alpha B & Bold 9900
My Carrier: Bell

Re: Invoking email with attachement - Broken with 10.2 ???

[ Edited ]

Only two little omission in the snippet provided by ... Missing one include :

 

#include <bb/PpsObject>

 

and tlink against this snippet, add the following line to your .pro file:

LIBS += -lbb

LIBS += -lbbsystem

Other then that, works like a charm !!! Thanks for the quick reply...

Please use plain text.
Developer
greenmr
Posts: 874
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: Invoking email with attachement - Broken with 10.2 ???

[ Edited ]

Just for the record, you could have done the exact same thing with my Invoker class like this:

 

#include "Invoker.hpp"
#include <bb/PpsObject>
void ApplicationUI::email() {
bool ok;
QVariantMap data; data["to"] = (QVariantList() << "someone@somewhere.com"); data["subject"] = "Message Title"; QVariantMap moreData; moreData["data"] = data; Invoker* invoker = invoker::create().parent(this).action("bb.action.COMPOSE").mimeType("message/rfc822").data(bb::PpsObject::encode(moreData, &ok)); invoker.invoke(); }

No need for this:

 

#include <bb/system/InvokeRequest>
#include <bb/system/InvokeManager>

using namespace bb::system;

Or this:

 

namespace bb
{
    namespace cascades
    {
        class Application;
        class LocaleHandler;
    }
    namespace system
    {
    	class InvokeManager;
    }
}

That said, it was 



Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.
Please use plain text.