Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Use Share Online Dialog in Qt

From Wiki
Jump to: navigation, search
Article Metadata
Code ExampleCompatibility
Created: teemup (12 May 2011)
Last edited: hamishwillee (11 Oct 2012)



Here in this article we will learn how to use the "share online" dialog to send images in Qt We will open the Social client in Symbian devices with a specific image file.

This solution will work if a Social client is present in the device. KAiwCmdUpload is used to find the service handling the uploading of the file to social networks. On some devices this service might not be the social client. This solution takes the first service suggested by the platform.

NOTE: The Social client assumes that the file exists. Please verify it before calling the method.

.PRO file

First step is to include necessary libary in the .pro file's symbian{} section.

symbian {
LIBS += -lservicehandler

Header file

In the header file of the class you plan to launch the request from:

#include <AiwServiceHandler.h>

Inside the class add this member variable:

     CAiwServiceHandler* iAiwServiceHandler;

Source file

In the constructor initialize the member variable and tell it that we will be interested in KAiwCmdEdit-services.

// ...
//Your other code here
iAiwServiceHandler = CAiwServiceHandler::NewL();
RCriteriaArray interest;
//We are interested on "KAiwCmdUpload" services that can handle images
_LIT8( KAllTypes, "image/*" );
CAiwCriteriaItem* criteria = CAiwCriteriaItem::NewLC(KAiwCmdUpload, KAiwCmdUpload, KAllTypes);
TUid base;
base.iUid = KAiwClassBase;
User::LeaveIfError(interest.Append( criteria));
CleanupStack::PopAndDestroy( criteria );
CleanupStack::PopAndDestroy( &interest );

And remember to reset and delete the variable in the destructor.

if ( iAiwServiceHandler )
delete iAiwServiceHandler;

Then add a method to do the request.

void MyClass::sendFileToSocial(QString file)
CAiwGenericParamList& inputParams = iAiwServiceHandler->InParamListL();
//Uid for starting the share process
TUid KUidForShare = { 2 };
TAiwVariant openVariant( KUidForShare );
TAiwGenericParam openParam( EGenericParamModeActivation, openVariant );
inputParams.AppendL( openParam );
TFileName filename(file.utf16());
TAiwGenericParam param(EGenericParamFile);
iAiwServiceHandler->ExecuteServiceCmdL(KAiwCmdUpload, inputParams, iAiwServiceHandler->OutParamListL());

NOTE: You can send multiple files by adding several params using TAiwGenericParam(EGenericParamFile).

Fixing the build error

You might get a build error concerning AiwCommon.h To fix it, do one change in it.

IMPORT_C TAiwVariant& TAiwVariant::operator=(const TAiwVariant& aValue);
IMPORT_C TAiwVariant& operator=(const TAiwVariant& aValue);

Download Source Code

The full source code presented in this article is available here

This page was last modified on 11 October 2012, at 01:18.
39 page views in the last 30 days.