Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'jb35260' into 'master'
[sharing] Show account icon on sharing list. Contributes to JB#35260

See merge request !5
  • Loading branch information
jpetrell committed Jan 12, 2018
2 parents e880654 + d0dcc75 commit ec3b91c
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 16 deletions.
6 changes: 6 additions & 0 deletions dbus/org.nemo.transferengine.xml
Expand Up @@ -88,6 +88,12 @@
# Get a list of transfer methods such as FB, Twitter, BT, NFC, etc
<method name="transferMethods">
<arg name="methods" type="a(ssssasi)" direction="out" />
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QList &lt; TransferMethodInfoDeprecated &gt; "/>
</method>

# Get a list of transfer methods such as FB, Twitter, BT, NFC, etc
<method name="transferMethods2">
<arg name="methods" type="a(ssssasusa{sv})" direction="out" />
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QList &lt; TransferMethodInfo&gt; "/>
</method>

Expand Down
2 changes: 2 additions & 0 deletions lib/metatypedeclarations.h
Expand Up @@ -33,6 +33,8 @@

Q_DECLARE_METATYPE(TransferDBRecord)
Q_DECLARE_METATYPE(QList<TransferDBRecord>)
Q_DECLARE_METATYPE(TransferMethodInfoDeprecated)
Q_DECLARE_METATYPE(QList<TransferMethodInfoDeprecated>)
Q_DECLARE_METATYPE(TransferMethodInfo)
Q_DECLARE_METATYPE(QList<TransferMethodInfo>)

Expand Down
58 changes: 48 additions & 10 deletions lib/transfermethodinfo.cpp
Expand Up @@ -46,6 +46,7 @@
info.displayName = QLatin1String("Bluetooth");
info.userName = "";
info.accountId = "";
info.accountIcon = QLatin1String("image://theme/icon-m-bluetooth");
info.methodId = QLatin1String("bluetooth");
info.shareUIPath = SHARE_UI_PATH + QLatin1String("/BluetoothShareUI.qml");
info.capabilitities = capabilities;
Expand All @@ -62,20 +63,15 @@
\value UserName User name e.g. mike.myers@gmail.com
\value MethodId The plugin Id of the share plugin e.g. "bluetooth"
\value AccountId The Id the account, needed in a case of multiple accounts
\value AccountIcon The url of the icon representing the account
\value ShareUIPath The path to the share ui QML plugin. This QML file will be loaded by the share UI
\value Capabilities A list of supported mimetypes
*/

/*!
Creates an instance of TransferMethodInfo.
*/
TransferMethodInfo::TransferMethodInfo():
displayName(),
userName(),
methodId(),
shareUIPath(),
capabilitities(),
accountId()
TransferMethodInfo::TransferMethodInfo()
{
}

Expand All @@ -90,6 +86,8 @@ TransferMethodInfo &TransferMethodInfo::operator=(const TransferMethodInfo &othe
shareUIPath = other.shareUIPath;
capabilitities = other.capabilitities;
accountId = other.accountId;
accountIcon = other.accountIcon;
hints = other.hints;
return *this;
}

Expand All @@ -102,7 +100,9 @@ TransferMethodInfo::TransferMethodInfo(const TransferMethodInfo &other):
methodId(other.methodId),
shareUIPath(other.shareUIPath),
capabilitities(other.capabilitities),
accountId(other.accountId)
accountId(other.accountId),
accountIcon(other.accountIcon),
hints(other.hints)
{

}
Expand All @@ -126,7 +126,9 @@ QDBusArgument &operator<<(QDBusArgument &argument, const TransferMethodInfo &inf
<< info.methodId
<< info.shareUIPath
<< info.capabilitities
<< info.accountId;
<< info.accountId
<< info.accountIcon
<< info.hints;

argument.endStructure();
return argument;
Expand All @@ -143,7 +145,9 @@ const QDBusArgument &operator>>(const QDBusArgument &argument, TransferMethodInf
>> info.methodId
>> info.shareUIPath
>> info.capabilitities
>> info.accountId;
>> info.accountId
>> info.accountIcon
>> info.hints;

argument.endStructure();
return argument;
Expand Down Expand Up @@ -176,7 +180,41 @@ QVariant TransferMethodInfo::value(int index) const
return capabilitities;
case AccountId:
return accountId;
case AccountIcon:
return accountIcon;
default:
return QVariant();
}
}

QDBusArgument &operator<<(QDBusArgument &argument, const TransferMethodInfoDeprecated &info)
{
argument.beginStructure();
argument << info.displayName
<< info.userName
<< info.methodId
<< info.shareUIPath
<< info.capabilitities
<< info.accountId;
argument.endStructure();
return argument;
}
const QDBusArgument &operator>>(const QDBusArgument &argument, TransferMethodInfoDeprecated &info)
{
argument.beginStructure();
argument >> info.displayName
>> info.userName
>> info.methodId
>> info.shareUIPath
>> info.capabilitities
>> info.accountId;

argument.endStructure();
return argument;
}

void TransferMethodInfoDeprecated::registerType()
{
qDBusRegisterMetaType<TransferMethodInfoDeprecated>();
qDBusRegisterMetaType<QList<TransferMethodInfoDeprecated> >();
}
24 changes: 21 additions & 3 deletions lib/transfermethodinfo.h
Expand Up @@ -30,6 +30,21 @@
#include <QtGlobal>
#include <QtDBus/QtDBus>

class TransferMethodInfoDeprecated
{
public:
friend QDBusArgument &operator<<(QDBusArgument &argument, const TransferMethodInfoDeprecated &record);
friend const QDBusArgument &operator>>(const QDBusArgument &argument, TransferMethodInfoDeprecated &record);

static void registerType();

QString displayName;
QString userName;
QString methodId;
QString shareUIPath;
QStringList capabilitities;
quint32 accountId;
};

class TransferMethodInfo
{
Expand All @@ -39,8 +54,9 @@ class TransferMethodInfo
enum TransferMethodInfoField {
DisplayName, // e.g. Facebook
UserName, // e.g. mike.myers@gmail.com
MethodId, // Id of the plugin
AccountId, // Id the account, needed in a case of multiple accounts
MethodId, // id of the plugin
AccountId, // id the account, needed in a case of multiple accounts
AccountIcon, // account icon source url
ShareUIPath, // path to the share ui QML plugin
Capabilities // list of supported mimetypes
};
Expand All @@ -57,13 +73,15 @@ class TransferMethodInfo

QVariant value(int index) const;


QString displayName;
QString userName;
QString methodId;
QString shareUIPath;
QStringList capabilitities;
quint32 accountId;
QString accountIcon;
QVariantHash hints;

};

#endif // TRANSFERMETHODINFO_H
24 changes: 22 additions & 2 deletions src/transferengine.cpp
Expand Up @@ -526,7 +526,6 @@ QList <TransferMethodInfo> TransferEnginePrivate::enabledPlugins() const
return m_enabledPlugins;
}


MediaTransferInterface *TransferEnginePrivate::loadPlugin(const QString &pluginId) const
{
QPluginLoader loader;
Expand Down Expand Up @@ -776,6 +775,7 @@ TransferEngine::TransferEngine(QObject *parent) :
QObject(parent),
d_ptr(new TransferEnginePrivate(this))
{
TransferMethodInfoDeprecated::registerType();
TransferMethodInfo::registerType();
TransferDBRecord::registerType();

Expand Down Expand Up @@ -1222,7 +1222,27 @@ QList<TransferDBRecord> TransferEngine::activeTransfers()
Transfer methods are basically a list of share plugins installed to the system.
*/
QList <TransferMethodInfo> TransferEngine::transferMethods()
QList <TransferMethodInfoDeprecated> TransferEngine::transferMethods()
{
Q_D(TransferEngine);
d->exitSafely();

QList <TransferMethodInfo> newPlugins = d->enabledPlugins();
QList <TransferMethodInfoDeprecated> oldPlugins;
for (auto info : newPlugins) {
TransferMethodInfoDeprecated oldInfo;
oldInfo.displayName = info.displayName;
oldInfo.userName = info.userName;
oldInfo.methodId = info.methodId;
oldInfo.shareUIPath = info.shareUIPath;
oldInfo.capabilitities = info.capabilitities;
oldInfo.accountId = info.accountId;
oldPlugins << oldInfo;
}
return oldPlugins;
}

QList <TransferMethodInfo> TransferEngine::transferMethods2()
{
Q_D(TransferEngine);
d->exitSafely();
Expand Down
3 changes: 2 additions & 1 deletion src/transferengine.h
Expand Up @@ -85,7 +85,8 @@ public Q_SLOTS:

QList<TransferDBRecord> activeTransfers();

QList <TransferMethodInfo> transferMethods();
QList <TransferMethodInfoDeprecated> transferMethods();
QList <TransferMethodInfo> transferMethods2();

void clearTransfers();

Expand Down

0 comments on commit ec3b91c

Please sign in to comment.