Skip to content

Commit

Permalink
Added share plugin example
Browse files Browse the repository at this point in the history
Added correct URL in spec file.

Removed autosaved file.
  • Loading branch information
Marko Mattila committed Apr 7, 2014
1 parent 5789f13 commit 7f2dd88
Show file tree
Hide file tree
Showing 9 changed files with 558 additions and 0 deletions.
81 changes: 81 additions & 0 deletions example/ExampleShareUI.qml
@@ -0,0 +1,81 @@
/****************************************************************************************
**
** Copyright (C) 2014 Jolla Ltd.
** Contact: Marko Mattila <marko.mattila@jolla.com>
** All rights reserved.
**
** This file is part of Nemo Transfer Engine package.
**
** You may use this file under the terms of the GNU Lesser General
** Public License version 2.1 as published by the Free Software Foundation
** and appearing in the file license.lgpl included in the packaging
** of this file.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file license.lgpl included in the packaging
** of this file.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
****************************************************************************************/

import QtQuick 2.0
import Sailfish.Silica 1.0
import org.nemomobile.thumbnailer 1.0
import Sailfish.TransferEngine 1.0

ShareDialog {
id: root

property int viewWidth: root.isPortrait ? Screen.width : Screen.width / 2

onAccepted: {
shareItem.start()
}

Thumbnail {
id: thumbnail
width: viewWidth
height: parent.height / 2
source: root.source
sourceSize.width: Screen.width
sourceSize.height: Screen.height / 2
}

Item {
anchors {
top: root.isPortrait ? thumbnail.bottom : parent.top
left: root.isPortrait ? parent.left: thumbnail.right
right: parent.right
bottom: parent.bottom
}

Label {
anchors.centerIn:parent
width: viewWidth
text: "Example Test Share UI"
horizontalAlignment: Text.AlignHCenter
}
}

SailfishShare {
id: shareItem
source: root.source
metadataStripped: true
serviceId: root.methodId
userData: {"description": "Random Text which can be what ever",
"accountId": root.accountId,
"scalePercent": root.scalePercent}
}

DialogHeader {
// TODO: Localization not supported for 3rd party plugins yet
acceptText: "Example Share"
}
}

64 changes: 64 additions & 0 deletions example/example.pro
@@ -0,0 +1,64 @@
TEMPLATE = lib
TARGET = $$qtLibraryTarget(exampleshareplugin)
CONFIG += plugin
DEPENDPATH += .

CONFIG += link_pkgconfig
PKGCONFIG += nemotransferengine-qt5

# Input
HEADERS += \
exampleplugininfo.h \
exampleuploader.h \
exampleshareplugin.h

SOURCES += \
exampleplugininfo.cpp \
exampleuploader.cpp \
exampleshareplugin.cpp

OTHER_FILES += \
ExampleShareUI.qml


shareui.files = *.qml
shareui.path = /usr/share/nemo-transferengine/plugins

target.path = /usr/lib/nemo-transferengine/plugins
INSTALLS += target shareui


TS_FILE = $$OUT_PWD/example_share_plugin.ts
EE_QM = $$OUT_PWD/example_share_plugin_eng_en.qm

ts.commands += lupdate . -ts $$TS_FILE
ts.CONFIG += no_check_exist no_link
ts.output = $$TS_FILE
ts.input = ..

ts_install.files = $$TS_FILE
ts_install.path = /usr/share/translations/source
ts_install.CONFIG += no_check_exist

# should add -markuntranslated "-" when proper translations are in place (or for testing)
engineering_english.commands += lrelease -idbased $$TS_FILE -qm $$EE_QM
engineering_english.CONFIG += no_check_exist no_link
engineering_english.depends = ts
engineering_english.input = $$TS_FILE
engineering_english.output = $$EE_QM

engineering_english_install.path = /usr/share/translations
engineering_english_install.files = $$EE_QM
engineering_english_install.CONFIG += no_check_exist

QMAKE_EXTRA_TARGETS += ts engineering_english

PRE_TARGETDEPS += ts engineering_english

INSTALLS += ts_install engineering_english_install



OTHER_FILES += \
rpm/*
translations/*
82 changes: 82 additions & 0 deletions example/exampleplugininfo.cpp
@@ -0,0 +1,82 @@
/****************************************************************************************
**
** Copyright (C) 2014 Jolla Ltd.
** Contact: Marko Mattila <marko.mattila@jolla.com>
** All rights reserved.
**
** This file is part of Nemo Transfer Engine package.
**
** You may use this file under the terms of the GNU Lesser General
** Public License version 2.1 as published by the Free Software Foundation
** and appearing in the file license.lgpl included in the packaging
** of this file.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file license.lgpl included in the packaging
** of this file.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
****************************************************************************************/

#include "exampleplugininfo.h"

ExamplePluginInfo::ExamplePluginInfo()
: m_ready(false)
{

}

ExamplePluginInfo::~ExamplePluginInfo()
{

}

QList<TransferMethodInfo> ExamplePluginInfo::info() const
{
return m_infoList;
}

void ExamplePluginInfo::query()
{
TransferMethodInfo info;
QStringList capabilities;

// Capabilites ie. what mimetypes this plugin supports
capabilities << QLatin1String("image/*")
<< QLatin1String("text/vcard");

// TODO: Translations for 3rd party plugins is not yet supported by Sailfish OS.
// Adding support there later, but for now just use what ever non-translated
// string here. This string will be visible in the share method list.
info.displayName = "Example Display Name";

// Method ID is a unique identifier for this plugin. It is used to identify which share plugin should be
// used for starting the sharing.
info.methodId = QLatin1String("Example-Share-Method-ID");

// Path to the Sharing UI which this plugin provides.
info.shareUIPath = QLatin1String("/usr/share/nemo-transferengine/plugins/ExampleShareUI.qml");

// Pass information about capabilities. This info is used for filtering share plugins
// which don't support defined types. For example, this plugin won't appear in the
// share method list, if someone tries to share content which isn't image or vcard type,
info.capabilitities = capabilities;

m_infoList << info;

// Let the world know that this plugin is ready
m_ready = true;
emit infoReady();
}


bool ExamplePluginInfo::ready() const
{
return m_ready;
}
46 changes: 46 additions & 0 deletions example/exampleplugininfo.h
@@ -0,0 +1,46 @@
/****************************************************************************************
**
** Copyright (C) 2014 Jolla Ltd.
** Contact: Marko Mattila <marko.mattila@jolla.com>
** All rights reserved.
**
** This file is part of Nemo Transfer Engine package.
**
** You may use this file under the terms of the GNU Lesser General
** Public License version 2.1 as published by the Free Software Foundation
** and appearing in the file license.lgpl included in the packaging
** of this file.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file license.lgpl included in the packaging
** of this file.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
****************************************************************************************/
#ifndef EXAMPLEPLUGININFO_H
#define EXAMPLEPLUGININFO_H

#include "transferplugininfo.h"

class ExamplePluginInfo : public TransferPluginInfo
{
Q_OBJECT
public:
ExamplePluginInfo();
~ExamplePluginInfo();

QList<TransferMethodInfo> info() const;
void query();
bool ready() const;
private:
QList<TransferMethodInfo> m_infoList;
bool m_ready;
};

#endif // EXAMPLEPLUGININFO_H
59 changes: 59 additions & 0 deletions example/exampleshareplugin.cpp
@@ -0,0 +1,59 @@
/****************************************************************************************
**
** Copyright (C) 2014 Jolla Ltd.
** Contact: Marko Mattila <marko.mattila@jolla.com>
** All rights reserved.
**
** This file is part of Nemo Transfer Engine package.
**
** You may use this file under the terms of the GNU Lesser General
** Public License version 2.1 as published by the Free Software Foundation
** and appearing in the file license.lgpl included in the packaging
** of this file.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file license.lgpl included in the packaging
** of this file.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
****************************************************************************************/

#include "exampleshareplugin.h"
#include "exampleuploader.h"
#include "exampleplugininfo.h"
#include <QtPlugin>

ExampleSharePlugin::ExampleSharePlugin()
{
}

ExampleSharePlugin::~ExampleSharePlugin()
{
}

MediaTransferInterface * ExampleSharePlugin::transferObject()
{
return new ExampleUploader;
}

TransferPluginInfo *ExampleSharePlugin::infoObject()
{
return new ExamplePluginInfo;
}

QString ExampleSharePlugin::pluginId() const
{
return "Example-Share-Method-ID";
}

bool ExampleSharePlugin::enabled() const
{
return true;
}

48 changes: 48 additions & 0 deletions example/exampleshareplugin.h
@@ -0,0 +1,48 @@
/****************************************************************************************
**
** Copyright (C) 2014 Jolla Ltd.
** Contact: Marko Mattila <marko.mattila@jolla.com>
** All rights reserved.
**
** This file is part of Nemo Transfer Engine package.
**
** You may use this file under the terms of the GNU Lesser General
** Public License version 2.1 as published by the Free Software Foundation
** and appearing in the file license.lgpl included in the packaging
** of this file.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file license.lgpl included in the packaging
** of this file.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
****************************************************************************************/

#ifndef EXAMPLESHAREPLUGIN_H
#define EXAMPLESHAREPLUGIN_H
#include "transferplugininterface.h"
#include <QObject>

class Q_DECL_EXPORT ExampleSharePlugin : public QObject, public TransferPluginInterface
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "com.myapp.transfer.plugin.example")
Q_INTERFACES(TransferPluginInterface)
public:
ExampleSharePlugin();
~ExampleSharePlugin();

MediaTransferInterface * transferObject();
TransferPluginInfo *infoObject();
QString pluginId() const;
bool enabled() const ;

};

#endif // EXAMPLESHAREPLUGIN_H

0 comments on commit 7f2dd88

Please sign in to comment.