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.

Changed licence information
  • Loading branch information
Marko Mattila committed May 5, 2014
1 parent 307a3c6 commit f3731ef
Show file tree
Hide file tree
Showing 9 changed files with 579 additions and 0 deletions.
84 changes: 84 additions & 0 deletions example/ExampleShareUI.qml
@@ -0,0 +1,84 @@
/******************************************************************************
Copyright (c) <2014>, Jolla Ltd.
Contact: Marko Mattila <marko.mattila@jolla.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer. Redistributions in binary
form must reproduce the above copyright notice, this list of conditions and
the following disclaimer in the documentation and/or other materials
provided with the distribution. Neither the name of the Jolla Ltd. nor
the names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/

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/*
85 changes: 85 additions & 0 deletions example/exampleplugininfo.cpp
@@ -0,0 +1,85 @@
/******************************************************************************
Copyright (c) <2014>, Jolla Ltd.
Contact: Marko Mattila <marko.mattila@jolla.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer. Redistributions in binary
form must reproduce the above copyright notice, this list of conditions and
the following disclaimer in the documentation and/or other materials
provided with the distribution. Neither the name of the Jolla Ltd. nor
the names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/

#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;
}
49 changes: 49 additions & 0 deletions example/exampleplugininfo.h
@@ -0,0 +1,49 @@
/******************************************************************************
Copyright (c) <2014>, Jolla Ltd.
Contact: Marko Mattila <marko.mattila@jolla.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer. Redistributions in binary
form must reproduce the above copyright notice, this list of conditions and
the following disclaimer in the documentation and/or other materials
provided with the distribution. Neither the name of the Jolla Ltd. nor
the names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#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
62 changes: 62 additions & 0 deletions example/exampleshareplugin.cpp
@@ -0,0 +1,62 @@
/******************************************************************************
Copyright (c) <2014>, Jolla Ltd.
Contact: Marko Mattila <marko.mattila@jolla.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer. Redistributions in binary
form must reproduce the above copyright notice, this list of conditions and
the following disclaimer in the documentation and/or other materials
provided with the distribution. Neither the name of the Jolla Ltd. nor
the names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/

#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;
}

0 comments on commit f3731ef

Please sign in to comment.