×
Namespaces

Variants
Actions

Use Share Online Dialog in Qt

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

Contents

Overview

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.

MyClass::MyClass()
{
// ...
//Your other code here
//
 
iAiwServiceHandler = CAiwServiceHandler::NewL();
 
RCriteriaArray interest;
CleanupClosePushL(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;
criteria->SetServiceClass(base);
 
User::LeaveIfError(interest.Append( criteria));
 
iAiwServiceHandler->AttachL(interest);
 
CleanupStack::PopAndDestroy( criteria );
CleanupStack::PopAndDestroy( &interest );
 
}

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

MyClass::~MyClass()
{
if ( iAiwServiceHandler )
{
iAiwServiceHandler->Reset();
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);
param.Value().Set(filename);
inputParams.AppendL(param);
 
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);
 
to
 
IMPORT_C TAiwVariant& operator=(const TAiwVariant& aValue);

Download Source Code

The full source code presented in this article is available here File:Sharedialog.zip

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

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×