mirror of
https://github.com/Ximi1970/systray-x.git
synced 2026-05-07 11:46:57 +02:00
Send platform and browser info to app
This commit is contained in:
@@ -69,6 +69,69 @@ void Preferences::setAppPrefChanged( bool state )
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set the platform os
|
||||
*/
|
||||
void Preferences::setPlatformOs( const QString os )
|
||||
{
|
||||
m_platform_os = os;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set the platform arch
|
||||
*/
|
||||
void Preferences::setPlatformArch( const QString arch )
|
||||
{
|
||||
m_platform_arch = arch;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set the platform native arch
|
||||
*/
|
||||
void Preferences::setPlatformNaclArch( const QString nacl_arch )
|
||||
{
|
||||
m_platform_nacl_arch = nacl_arch;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set the browser name
|
||||
*/
|
||||
void Preferences::setBrowserName( const QString name )
|
||||
{
|
||||
m_browser_name = name;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set the browser
|
||||
*/
|
||||
void Preferences::setBrowserVendor( const QString vendor )
|
||||
{
|
||||
m_browser_vendor = vendor;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set the browser
|
||||
*/
|
||||
void Preferences::setBrowserVersion( const QString version )
|
||||
{
|
||||
m_browser_version = version;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set the browser
|
||||
*/
|
||||
void Preferences::setBrowserBuildID( const QString buildID )
|
||||
{
|
||||
m_browser_buildID = buildID;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the icon type.
|
||||
*/
|
||||
|
||||
@@ -60,6 +60,55 @@ class Preferences : public QObject
|
||||
*/
|
||||
void setAppPrefChanged( bool state );
|
||||
|
||||
/**
|
||||
* @brief setPlatformOs. Set the platform OS.
|
||||
*
|
||||
* @param os The platform os.
|
||||
*/
|
||||
void setPlatformOs( const QString os );
|
||||
|
||||
/**
|
||||
* @brief setPlatformArch. Set the platform architecture.
|
||||
*
|
||||
* @param arch The architecture.
|
||||
*/
|
||||
void setPlatformArch( const QString arch );
|
||||
|
||||
/**
|
||||
* @brief setPlatformNaclArch. Set the native platform architecture.
|
||||
*
|
||||
* @param nacl_arch The native architecture.
|
||||
*/
|
||||
void setPlatformNaclArch( const QString nacl_arch );
|
||||
|
||||
/**
|
||||
* @brief setBrowserName. Set the browser name.
|
||||
*
|
||||
* @param name The name.
|
||||
*/
|
||||
void setBrowserName( const QString name );
|
||||
|
||||
/**
|
||||
* @brief setBrowserVendor. Set the browser vendor.
|
||||
*
|
||||
* @param vendor The vendor.
|
||||
*/
|
||||
void setBrowserVendor( const QString vendor );
|
||||
|
||||
/**
|
||||
* @brief setBrowserVersion. Set the browser version.
|
||||
*
|
||||
* @param version The version.
|
||||
*/
|
||||
void setBrowserVersion( const QString version );
|
||||
|
||||
/**
|
||||
* @brief setBrowserBuildID. set the build id.
|
||||
*
|
||||
* @param buildID The id.
|
||||
*/
|
||||
void setBrowserBuildID( const QString buildID );
|
||||
|
||||
/**
|
||||
* @brief getIconType. Get the icon type.
|
||||
*
|
||||
@@ -289,6 +338,21 @@ class Preferences : public QObject
|
||||
*/
|
||||
bool m_app_pref_changed;
|
||||
|
||||
/**
|
||||
* @brief m_platform_xx. Platform description.
|
||||
*/
|
||||
QString m_platform_os;
|
||||
QString m_platform_arch;
|
||||
QString m_platform_nacl_arch;
|
||||
|
||||
/**
|
||||
* @brief m_browser_xx. Browser description.
|
||||
*/
|
||||
QString m_browser_name;
|
||||
QString m_browser_vendor;
|
||||
QString m_browser_version;
|
||||
QString m_browser_buildID;
|
||||
|
||||
/**
|
||||
* @brief m_icon_type. Selected icon type.
|
||||
*/
|
||||
|
||||
@@ -317,6 +317,16 @@ void SysTrayXLink::DecodeMessage( const QByteArray& message )
|
||||
emit signalWindowState( window_state );
|
||||
}
|
||||
|
||||
if( jsonObject.contains( "platformInfo" ) && jsonObject[ "platformInfo" ].isObject() )
|
||||
{
|
||||
DecodePlatform( jsonObject[ "platformInfo" ].toObject() );
|
||||
}
|
||||
|
||||
if( jsonObject.contains( "browserInfo" ) && jsonObject[ "browserInfo" ].isObject() )
|
||||
{
|
||||
DecodeBrowser( jsonObject[ "browserInfo" ].toObject() );
|
||||
}
|
||||
|
||||
if( jsonObject.contains( "preferences" ) && jsonObject[ "preferences" ].isObject() )
|
||||
{
|
||||
DecodePreferences( jsonObject[ "preferences" ].toObject() );
|
||||
@@ -325,11 +335,101 @@ void SysTrayXLink::DecodeMessage( const QByteArray& message )
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Decode platform from JSON message
|
||||
*/
|
||||
void SysTrayXLink::DecodePlatform( const QJsonObject& platform )
|
||||
{
|
||||
/*
|
||||
* Check the received object
|
||||
*/
|
||||
if( platform.contains( "os" ) && platform[ "os" ].isString() )
|
||||
{
|
||||
QString os = platform[ "os" ].toString();
|
||||
|
||||
/*
|
||||
* Store the os
|
||||
*/
|
||||
m_pref->setPlatformOs( os );
|
||||
}
|
||||
|
||||
if( platform.contains( "arch" ) && platform[ "arch" ].isString() )
|
||||
{
|
||||
QString arch = platform[ "arch" ].toString();
|
||||
|
||||
/*
|
||||
* Store the arch
|
||||
*/
|
||||
m_pref->setPlatformArch( arch );
|
||||
}
|
||||
|
||||
if( platform.contains( "nacl_arch" ) && platform[ "nacl_arch" ].isString() )
|
||||
{
|
||||
QString nacl_arch = platform[ "nacl_arch" ].toString();
|
||||
|
||||
/*
|
||||
* Store the nacl_arch
|
||||
*/
|
||||
m_pref->setPlatformNaclArch( nacl_arch );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Decode platform from JSON message
|
||||
*/
|
||||
void SysTrayXLink::DecodeBrowser( const QJsonObject& browser )
|
||||
{
|
||||
/*
|
||||
* Check the received object
|
||||
*/
|
||||
if( browser.contains( "name" ) && browser[ "name" ].isString() )
|
||||
{
|
||||
QString name = browser[ "name" ].toString();
|
||||
|
||||
/*
|
||||
* Store the name
|
||||
*/
|
||||
m_pref->setBrowserName( name );
|
||||
}
|
||||
|
||||
if( browser.contains( "vendor" ) && browser[ "vendor" ].isString() )
|
||||
{
|
||||
QString vendor = browser[ "vendor" ].toString();
|
||||
|
||||
/*
|
||||
* Store the vendor
|
||||
*/
|
||||
m_pref->setBrowserVendor( vendor );
|
||||
}
|
||||
|
||||
if( browser.contains( "version" ) && browser[ "version" ].isString() )
|
||||
{
|
||||
QString version = browser[ "version" ].toString();
|
||||
|
||||
/*
|
||||
* Store the version
|
||||
*/
|
||||
m_pref->setBrowserVersion( version );
|
||||
}
|
||||
|
||||
if( browser.contains( "buildID" ) && browser[ "buildID" ].isString() )
|
||||
{
|
||||
QString buildID = browser[ "buildID" ].toString();
|
||||
|
||||
/*
|
||||
* Store the buildID
|
||||
*/
|
||||
m_pref->setBrowserBuildID( buildID );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Decode preferences from JSON message
|
||||
*/
|
||||
void SysTrayXLink::DecodePreferences( const QJsonObject& pref )
|
||||
{
|
||||
{
|
||||
/*
|
||||
* Check the received object
|
||||
*/
|
||||
|
||||
@@ -129,6 +129,20 @@ class SysTrayXLink : public QObject
|
||||
*/
|
||||
void DecodeMessage( const QByteArray& message );
|
||||
|
||||
/**
|
||||
* @brief DecodePlatform. Decode a JSON platform object.
|
||||
*
|
||||
* @param platform The JSON platform.
|
||||
*/
|
||||
void DecodePlatform( const QJsonObject& platform );
|
||||
|
||||
/**
|
||||
* @brief DecodeBrowser. Decode a JSON browser object.
|
||||
*
|
||||
* @param browser The JSON browser.
|
||||
*/
|
||||
void DecodeBrowser( const QJsonObject& browser );
|
||||
|
||||
/**
|
||||
* @brief DecodePreferences. Decode a JSON preference object.
|
||||
*
|
||||
|
||||
@@ -10,6 +10,8 @@ var SysTrayX = {
|
||||
|
||||
platformInfo: undefined,
|
||||
|
||||
browserInfo: undefined,
|
||||
|
||||
version: "0",
|
||||
};
|
||||
|
||||
@@ -26,6 +28,12 @@ SysTrayX.Messaging = {
|
||||
// Lookout for storage changes
|
||||
browser.storage.onChanged.addListener(SysTrayX.Messaging.storageChanged);
|
||||
|
||||
// Send the platform info to app
|
||||
SysTrayX.Messaging.sendPlatformInfo();
|
||||
|
||||
// Send the browser info to app
|
||||
SysTrayX.Messaging.sendBrowserInfo();
|
||||
|
||||
// Send the window title to app
|
||||
SysTrayX.Messaging.sendTitle();
|
||||
|
||||
@@ -142,6 +150,16 @@ SysTrayX.Messaging = {
|
||||
SysTrayX.Link.postSysTrayXMessage({ unreadMail: count });
|
||||
},
|
||||
|
||||
sendBrowserInfo: function () {
|
||||
const info = SysTrayX.browserInfo;
|
||||
SysTrayX.Link.postSysTrayXMessage({ browserInfo: browserInfo });
|
||||
},
|
||||
|
||||
sendPlatformInfo: function () {
|
||||
const info = SysTrayX.platformInfo;
|
||||
SysTrayX.Link.postSysTrayXMessage({ platformInfo: platformInfo });
|
||||
},
|
||||
|
||||
sendTitle: function () {
|
||||
const title = "-" + SysTrayX.Window.startWindow.title.split("-").pop();
|
||||
SysTrayX.Link.postSysTrayXMessage({ title: title });
|
||||
@@ -387,7 +405,7 @@ async function start() {
|
||||
|
||||
SysTrayX.startupState = state;
|
||||
|
||||
console.debug("State: "+ SysTrayX.startupState);
|
||||
console.debug("State: " + SysTrayX.startupState);
|
||||
|
||||
// Get the poll timing
|
||||
SysTrayX.pollTiming = await getPollTiming();
|
||||
@@ -406,6 +424,21 @@ async function start() {
|
||||
platformInfo: SysTrayX.platformInfo,
|
||||
});
|
||||
|
||||
// Set browser
|
||||
SysTrayX.browserInfo = await browser.runtime
|
||||
.getBrowserInfo()
|
||||
.then((info) => info);
|
||||
|
||||
console.log("Browser: " + SysTrayX.browserInfo.name);
|
||||
console.log("Vendor: " + SysTrayX.browserInfo.vendor);
|
||||
console.log("Version: " + SysTrayX.browserInfo.version);
|
||||
console.log("Build: " + SysTrayX.browserInfo.buildID);
|
||||
|
||||
// Store browser info
|
||||
browser.storage.sync.set({
|
||||
browserInfo: SysTrayX.browserInfo,
|
||||
});
|
||||
|
||||
// Get addon version
|
||||
SysTrayX.version = browser.runtime.getManifest().version;
|
||||
console.log("Addon version: " + SysTrayX.version);
|
||||
|
||||
Reference in New Issue
Block a user