Skip to content

Commit

Permalink
refactor share-plugin settings to be part of the plguin completely
Browse files Browse the repository at this point in the history
  • Loading branch information
jangernert committed Feb 23, 2017
1 parent 4d34675 commit ce70163
Show file tree
Hide file tree
Showing 24 changed files with 153 additions and 114 deletions.
1 change: 1 addition & 0 deletions plugins/share/Instapaper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ add_dependencies(${NAME} ${UI_NAME} ${DAEMON_NAME})

install(TARGETS ${NAME} DESTINATION ${PKGLIBDIR}/pluginsShare)
install(FILES ${NAME}.plugin DESTINATION ${PKGLIBDIR}/pluginsShare)
add_schema ("org.gnome.feedreader.share.instapaper.gschema.xml")

8 changes: 4 additions & 4 deletions plugins/share/Instapaper/InstapaperAPI.vala
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ public class FeedReader.InstaAPI : ShareAccountInterface, Peas.ExtensionBase {
settings.set_string("username", username);
settings.set_string("user-id", userID);

var array = Settings.share().get_strv("instapaper");
var array = Settings.share("instapaper").get_strv("account-ids");
array += id;
Settings.share().set_strv("instapaper", array);
Settings.share("instapaper").set_strv("account-ids", array);

var pwSchema = new Secret.Schema ("org.gnome.feedreader.instapaper.password", Secret.SchemaFlags.NONE,
"userID", Secret.SchemaAttributeType.STRING);
Expand Down Expand Up @@ -223,15 +223,15 @@ public class FeedReader.InstaAPI : ShareAccountInterface, Peas.ExtensionBase {
settings.reset(key);
}

var array = Settings.share().get_strv("instapaper");
var array = Settings.share("instapaper").get_strv("account-ids");

string[] array2 = {};
foreach(string i in array)
{
if(i != id)
array2 += i;
}
Settings.share().set_strv("instapaper", array2);
Settings.share("instapaper").set_strv("account-ids", array2);
deleteAccount(id);

return true;
Expand Down
2 changes: 1 addition & 1 deletion plugins/share/Instapaper/InstapaperSetup.vala
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class FeedReader.InstapaperSetup : ServiceSetup {
{
m_spinner.start();
m_iconStack.set_visible_child_name("spinner");
string id = Share.generateNewID();
string id = Share.get_default().generateNewID();
string username = m_userEntry.get_text();
string password = m_passEntry.get_text();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<schemalist>
<schema id="org.gnome.feedreader.share.instapaper" path="/org/gnome/feedreader/share/instapaper/" gettext-domain="feedreader">

<key name="account-ids" type="as">
<default>[]</default>
<summary>instapaper accounts</summary>
<description>
all the instapaper account ids
</description>
</key>

</schema>
</schemalist>
1 change: 1 addition & 0 deletions plugins/share/Pocket/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ add_dependencies(${NAME} ${UI_NAME} ${DAEMON_NAME})

install(TARGETS ${NAME} DESTINATION ${PKGLIBDIR}/pluginsShare)
install(FILES ${NAME}.plugin DESTINATION ${PKGLIBDIR}/pluginsShare)
add_schema ("org.gnome.feedreader.share.pocket.gschema.xml")

8 changes: 4 additions & 4 deletions plugins/share/Pocket/PocketAPI.vala
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ public class FeedReader.PocketAPI : ShareAccountInterface, Peas.ExtensionBase {
settings.set_string("oauth-access-token", accessToken);
settings.set_string("username", user);

var array = Settings.share().get_strv("pocket");
var array = Settings.share("pocket").get_strv("account-ids");
array += id;
Settings.share().set_strv("pocket", array);
Settings.share("pocket").set_strv("account-ids", array);

return true;
}
Expand Down Expand Up @@ -194,15 +194,15 @@ public class FeedReader.PocketAPI : ShareAccountInterface, Peas.ExtensionBase {
settings.reset(key);
}

var array = Settings.share().get_strv("pocket");
var array = Settings.share("pocket").get_strv("account-ids");
string[] array2 = {};

foreach(string i in array)
{
if(i != id)
array2 += i;
}
Settings.share().set_strv("pocket", array2);
Settings.share("pocket").set_strv("account-ids", array2);
deleteAccount(id);

return true;
Expand Down
2 changes: 1 addition & 1 deletion plugins/share/Pocket/PocketSetup.vala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class FeedReader.PocketSetup : ServiceSetup {

public override void login()
{
string id = Share.generateNewID();
string id = Share.get_default().generateNewID();
string requestToken = m_api.getRequestToken();
string url = m_api.getURL(requestToken);
m_spinner.start();
Expand Down
13 changes: 13 additions & 0 deletions plugins/share/Pocket/org.gnome.feedreader.share.pocket.gschema.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<schemalist>
<schema id="org.gnome.feedreader.share.pocket" path="/org/gnome/feedreader/share/pocket/" gettext-domain="feedreader">

<key name="account-ids" type="as">
<default>[]</default>
<summary>pocket accounts</summary>
<description>
all the pocket account ids
</description>
</key>

</schema>
</schemalist>
1 change: 1 addition & 0 deletions plugins/share/Telegram/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ add_dependencies(${NAME} ${UI_NAME} ${DAEMON_NAME})

install(TARGETS ${NAME} DESTINATION ${PKGLIBDIR}/pluginsShare)
install(FILES ${NAME}.plugin DESTINATION ${PKGLIBDIR}/pluginsShare)
add_schema ("org.gnome.feedreader.share.telegram.gschema.xml")

53 changes: 27 additions & 26 deletions plugins/share/Telegram/Telegram.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public class FeedReader.Telegram : ShareAccountInterface, Peas.ExtensionBase {

public bool addTelegram(string id, string username)
{
var settings = new GLib.Settings.with_path("org.gnome.feedreader.share.account", "/org/gnome/feedreader/share/telegram/%s/".printf(id));
var settings = new GLib.Settings.with_path("org.gnome.feedreader.share.account", "/org/gnome/feedreader/share/telegram/%s/".printf(id));
settings.set_string("username", username);
var array = Settings.share().get_strv("telegram");
var array = Settings.share("telegram").get_strv("account-ids");
foreach(string i in array)
{
if(i == id)
Expand All @@ -31,8 +31,9 @@ public class FeedReader.Telegram : ShareAccountInterface, Peas.ExtensionBase {
return false;
}
}
array += id;
Settings.share().set_strv("telegram", array);

array += id;
Settings.share("telegram").set_strv("account-ids", array);

return true;
}
Expand Down Expand Up @@ -62,29 +63,29 @@ public class FeedReader.Telegram : ShareAccountInterface, Peas.ExtensionBase {
{
Logger.debug(@"Telegram.remove($id)");
var settings = new GLib.Settings.with_path("org.gnome.feedreader.share.account", "/org/gnome/feedreader/share/telegram/%s/".printf(id));
var keys = settings.list_keys();
var keys = settings.list_keys();
foreach(string key in keys)
{
settings.reset(key);
}

var array = Settings.share().get_strv("telegram");
string[] array2 = {};
var array = Settings.share("telegram").get_strv("account-ids");
string[] array2 = {};

foreach(string i in array)
foreach(string i in array)
{
if(i != id)
array2 += i;
}
Settings.share().set_strv("telegram", array2);
Settings.share("telegram").set_strv("account-ids", array2);
deleteAccount(id);
return true;
}

public string getIconName()
{
return "feed-share-telegram";
}
{
return "feed-share-telegram";
}

public string getUsername(string id)
{
Expand All @@ -97,29 +98,29 @@ public class FeedReader.Telegram : ShareAccountInterface, Peas.ExtensionBase {
}

public bool useSystemAccounts()
{
return false;
}
{
return false;
}

public string pluginID()
{
return "telegram";
}
{
return "telegram";
}

public string pluginName()
{
return _("Telegram");
}

public ServiceSetup? newSetup_withID(string id, string username)
{
return new TelegramSetup(id, this, username);
}

public ServiceSetup? newSetup()
{
return new TelegramSetup(null, this);
}
{
return new TelegramSetup(id, this, username);
}

public ServiceSetup? newSetup()
{
return new TelegramSetup(null, this);
}

public ServiceSetup? newSystemAccount(string id, string username)
{
Expand Down
1 change: 0 additions & 1 deletion plugins/share/Telegram/TelegramForm.vala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

public class FeedReader.TelegramForm : ShareForm {

private Gtk.Entry m_entry;
private Gtk.TextView m_textView;

public TelegramForm()
Expand Down
4 changes: 2 additions & 2 deletions plugins/share/Telegram/TelegramSetup.vala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class FeedReader.TelegramSetup : ServiceSetup {
loggedIN = true;

base("Telegram", "feed-share-telegram", loggedIN, username);

m_tg = tg;
//no login, so change the labels
m_login_button.set_label(_("Add"));
Expand All @@ -37,7 +37,7 @@ public class FeedReader.TelegramSetup : ServiceSetup {

public override void login()
{
showInfoBar(_("Telegram needs to be installed on your system!."));
showInfoBar(_("Telegram needs to be installed on your system."));
//use static id to determin if already added
string id = "X-URL-SCHEME-TELEGRAM";
string username = m_tg.getUsername(id);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<schemalist>
<schema id="org.gnome.feedreader.share.telegram" path="/org/gnome/feedreader/share/telegram/" gettext-domain="feedreader">

<key name="account-ids" type="as">
<default>[]</default>
<summary>Telegram accounts</summary>
<description>
all the telegram account ids
</description>
</key>

</schema>
</schemalist>
1 change: 1 addition & 0 deletions plugins/share/Twitter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ add_dependencies(${NAME} ${UI_NAME} ${DAEMON_NAME})

install(TARGETS ${NAME} DESTINATION ${PKGLIBDIR}/pluginsShare)
install(FILES ${NAME}.plugin DESTINATION ${PKGLIBDIR}/pluginsShare)
add_schema ("org.gnome.feedreader.share.twitter.gschema.xml")

10 changes: 5 additions & 5 deletions plugins/share/Twitter/TwitterAPI.vala
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ public class FeedReader.TwitterAPI : ShareAccountInterface, Peas.ExtensionBase {



var array = Settings.share().get_strv("twitter");
var array = Settings.share("twitter").get_strv("account-ids");
array += id;
Settings.share().set_strv("twitter", array);
Settings.share("twitter").set_strv("account-ids", array);

return true;
}
Expand Down Expand Up @@ -165,15 +165,15 @@ public class FeedReader.TwitterAPI : ShareAccountInterface, Peas.ExtensionBase {
settings.reset(key);
}

var array = Settings.share().get_strv("twitter");
var array = Settings.share("twitter").get_strv("account-ids");
string[] array2 = {};

foreach(string i in array)
{
if(i != id)
array2 += i;
}
Settings.share().set_strv("twitter", array2);
Settings.share("twitter").set_strv("account-ids", array2);
deleteAccount(id);

return true;
Expand Down Expand Up @@ -250,7 +250,7 @@ public class FeedReader.TwitterAPI : ShareAccountInterface, Peas.ExtensionBase {
if(m_urlLength > 0)
return m_urlLength;

var array = Settings.share().get_strv("twitter");
var array = Settings.share("twitter").get_strv("account-ids");
string id = array[0];

var settings = new GLib.Settings.with_path("org.gnome.feedreader.share.account", "/org/gnome/feedreader/share/twitter/%s/".printf(id));
Expand Down
2 changes: 1 addition & 1 deletion plugins/share/Twitter/TwitterSetup.vala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class FeedReader.TwitterSetup : ServiceSetup {

public override void login()
{
string id = Share.generateNewID();
string id = Share.get_default().generateNewID();
string requestToken = m_api.getRequestToken();
string url = m_api.getURL(requestToken);
m_spinner.start();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<schemalist>
<schema id="org.gnome.feedreader.share.twitter" path="/org/gnome/feedreader/share/twitter/" gettext-domain="feedreader">

<key name="account-ids" type="as">
<default>[]</default>
<summary>twitter accounts</summary>
<description>
all the twitter account ids
</description>
</key>

</schema>
</schemalist>
1 change: 1 addition & 0 deletions plugins/share/Wallabag/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ add_dependencies(${NAME} ${UI_NAME} ${DAEMON_NAME})

install(TARGETS ${NAME} DESTINATION ${PKGLIBDIR}/pluginsShare)
install(FILES ${NAME}.plugin DESTINATION ${PKGLIBDIR}/pluginsShare)
add_schema ("org.gnome.feedreader.share.wallabag.gschema.xml")

8 changes: 4 additions & 4 deletions plugins/share/Wallabag/WallabagAPI.vala
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public class FeedReader.WallabagAPI : ShareAccountInterface, Peas.ExtensionBase
settings.set_string("client-secret", clientSecret);


var array = Settings.share().get_strv("wallabag");
var array = Settings.share("wallabag").get_strv("wallabag");
foreach(string i in array)
{
if(i == id)
Expand All @@ -105,7 +105,7 @@ public class FeedReader.WallabagAPI : ShareAccountInterface, Peas.ExtensionBase
}
}
array += id;
Settings.share().set_strv("wallabag", array);
Settings.share("wallabag").set_strv("wallabag", array);


var pwSchema = new Secret.Schema ("org.gnome.feedreader.wallabag.password", Secret.SchemaFlags.NONE,
Expand Down Expand Up @@ -180,15 +180,15 @@ public class FeedReader.WallabagAPI : ShareAccountInterface, Peas.ExtensionBase
settings.reset(key);
}

var array = Settings.share().get_strv("wallabag");
var array = Settings.share("wallabag").get_strv("wallabag");
string[] array2 = {};

foreach(string i in array)
{
if(i != id)
array2 += i;
}
Settings.share().set_strv("wallabag", array2);
Settings.share("wallabag").set_strv("wallabag", array2);
deleteAccount(id);

return true;
Expand Down
2 changes: 1 addition & 1 deletion plugins/share/Wallabag/WallabagSetup.vala
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public class FeedReader.WallabagSetup : ServiceSetup {
{
if(m_login_revealer.get_child_revealed())
{
string id = Share.generateNewID();
string id = Share.get_default().generateNewID();
string username = m_userEntry.get_text();
string password = m_passEntry.get_text();
string clientID = m_idEntry.get_text();
Expand Down
Loading

0 comments on commit ce70163

Please sign in to comment.