Commit d0dcc756 authored by jpetrell's avatar jpetrell

[sharing] Show account icon on sharing list. Contributes to JB#35260

parent e8806542
......@@ -88,7 +88,13 @@
# 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; TransferMethodInfo &gt; "/>
<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>
# clear all unfinished transfers
......
......@@ -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>)
......
......@@ -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;
......@@ -62,6 +63,7 @@
\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
*/
......@@ -69,13 +71,7 @@
/*!
Creates an instance of TransferMethodInfo.
*/
TransferMethodInfo::TransferMethodInfo():
displayName(),
userName(),
methodId(),
shareUIPath(),
capabilitities(),
accountId()
TransferMethodInfo::TransferMethodInfo()
{
}
......@@ -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;
}
......@@ -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)
{
}
......@@ -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;
......@@ -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;
......@@ -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> >();
}
......@@ -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
{
......@@ -39,8 +54,9 @@ public:
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
};
......@@ -57,13 +73,15 @@ public:
QVariant value(int index) const;
QString displayName;
QString userName;
QString methodId;
QString shareUIPath;
QStringList capabilitities;
quint32 accountId;
QString accountIcon;
QVariantHash hints;
};
#endif // TRANSFERMETHODINFO_H
......@@ -526,7 +526,6 @@ QList <TransferMethodInfo> TransferEnginePrivate::enabledPlugins() const
return m_enabledPlugins;
}
MediaTransferInterface *TransferEnginePrivate::loadPlugin(const QString &pluginId) const
{
QPluginLoader loader;
......@@ -776,6 +775,7 @@ TransferEngine::TransferEngine(QObject *parent) :
QObject(parent),
d_ptr(new TransferEnginePrivate(this))
{
TransferMethodInfoDeprecated::registerType();
TransferMethodInfo::registerType();
TransferDBRecord::registerType();
......@@ -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();
......
......@@ -85,7 +85,8 @@ public Q_SLOTS:
QList<TransferDBRecord> activeTransfers();
QList <TransferMethodInfo> transferMethods();
QList <TransferMethodInfoDeprecated> transferMethods();
QList <TransferMethodInfo> transferMethods2();
void clearTransfers();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment