diff --git a/mysc/keys/api_keys.c b/mysc/keys/api_keys.c new file mode 100644 index 00000000..a3c5ad09 --- /dev/null +++ b/mysc/keys/api_keys.c @@ -0,0 +1,23 @@ +#include "api_keys.h" +char *get_api_key(){ +return "key\0"; +} +char *get_api_secret(){ +return "secret_key\0"; +} +char *get_dropbox_api_key(){ +return "key\0"; +} +char *get_dropbox_api_secret(){ +return "secret_key\0"; +} +char *get_twishort_api_key(){ +return "key\0"; +} +char *get_bts_user(){ +return "user\0"; +} +char *get_bts_password(){ +return "pass\0"; +} + diff --git a/mysc/keys/api_keys.h b/mysc/keys/api_keys.h new file mode 100644 index 00000000..963403ce --- /dev/null +++ b/mysc/keys/api_keys.h @@ -0,0 +1,12 @@ +#ifndef _API_KEYS_H +#define API_KEYS_H + +char *get_api_key(); +char *get_api_secret(); +char *get_dropbox_api_key(); +char *get_dropbox_api_secret(); +char *get_twishort_api_key(); +char *get_bts_user(); +char *get_bts_password(); + +#endif diff --git a/src/application.py b/src/application.py index 66eff230..4ce1a0a2 100644 --- a/src/application.py +++ b/src/application.py @@ -14,7 +14,3 @@ description = u"TW Blue is an app designed to use Twitter in a simple and fast w translators = [u"Bryner Villalobos (English)", u"Mohammed Al Shara (Arabic)", u"Salva Doménech, Juan Carlos Rivilla(Catalan)", u"Manuel cortéz(Spanish)", u"Sukil Etxenike Arizaleta(Basque)", u"Jani Kinnunen(finnish)", u"Javier Currás, José Manuel Delicado, Alba Quinteiro(Galician)", u"Robert Osztolykan(Hungarian)", u"Paweł Masarczyk(Polish)", u"Odenilton Júnior Santos(Portuguese)", u"Alexander Jaszyn(Russian)", u"Burak (Turkish)"] url = u"http://twblue.com.mx" report_bugs_url = "http://twblue.com.mx/errores/api/soap/mantisconnect.php?wsdl" - -# Tokens -app_key = '8pDLbyOW3saYnvSZ4uLFg' -app_secret = 'YsgdrzY9B4yyYvYsyee78rKI3GshjHpenVS9LnFJXY' \ No newline at end of file diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 063adfb1..ee2a314a 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -88,7 +88,7 @@ class Controller(object): pub.subscribe(self.manage_blocked_user, "blocked-user") pub.subscribe(self.manage_unblocked_user, "unblocked-user") pub.subscribe(self.manage_item_in_timeline, "item-in-timeline") - widgetUtils.connect_event(self.view, widgetUtils.CLOSE_EVENT, self.exit) + widgetUtils.connect_event(self.view, widgetUtils.CLOSE_EVENT, self.exit_) def bind_other_events(self): log.debug("Binding other application events...") @@ -104,7 +104,7 @@ class Controller(object): widgetUtils.connect_event(self.view, widgetUtils.MENU, self.exit, menuitem=self.view.close) if widgetUtils.toolkit == "wx": log.debug("Binding the exit function...") - widgetUtils.connectExitFunction(self.exit) + widgetUtils.connectExitFunction(self.exit_) widgetUtils.connect_event(self.view, widgetUtils.MENU, self.post_tweet, self.view.compose) widgetUtils.connect_event(self.view, widgetUtils.MENU, self.post_reply, self.view.reply) widgetUtils.connect_event(self.view, widgetUtils.MENU, self.post_retweet, self.view.retweet) diff --git a/src/extra/AudioUploader/dropbox_transfer.py b/src/extra/AudioUploader/dropbox_transfer.py index e7aa5f42..5d68fc10 100644 --- a/src/extra/AudioUploader/dropbox_transfer.py +++ b/src/extra/AudioUploader/dropbox_transfer.py @@ -5,6 +5,7 @@ import os import exceptions import dropbox import logging +from keys import keyring from utils import * from dropbox.rest import ErrorResponse from StringIO import StringIO @@ -42,13 +43,11 @@ class dropboxLogin(object): def __init__(self, config): log.debug("Trying to login in Dropbox...") self.logged = False - self.app_key = "c8ikm0gexqvovol" - self.app_secret = "gvvi6fzfecooast" self.config = config def get_url(self): log.debug("Getting autorisation URL...") - self.flow = dropbox.client.DropboxOAuth2FlowNoRedirect(self.app_key, self.app_secret) + self.flow = dropbox.client.DropboxOAuth2FlowNoRedirect(keyring.get("dropbox_app_key"), keyring.get("dropbox_app_secret")) return self.flow.start() def authorise(self, code): diff --git a/src/keys/__init__.py b/src/keys/__init__.py new file mode 100644 index 00000000..d5c44272 --- /dev/null +++ b/src/keys/__init__.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +import platform +import exceptions +from ctypes import c_char_p +from libloader import load_library +import paths +if platform.architecture()[0][:2] == "32": + lib = load_library("api_keys32", x86_path=paths.app_path("keys/lib")) +else: + lib = load_library("api_keys64", x64_path=paths.app_path("keys/lib")) + +keyring = None + +def setup(): + global keyring + if keyring == None: + keyring = Keyring() + +class Keyring(object): + def __init__(self): + super(Keyring, self).__init__() + + def _call_method(self, function): + result = getattr(lib, function) + result = c_char_p(result.__call__()) + return result.value + + def get(self, func): + return getattr(self, "_call_method")("get_"+func) \ No newline at end of file diff --git a/src/keys/lib/api_keys32.dll b/src/keys/lib/api_keys32.dll new file mode 100644 index 00000000..8e9749f8 Binary files /dev/null and b/src/keys/lib/api_keys32.dll differ diff --git a/src/main.py b/src/main.py index c2b0d412..a721bdc5 100644 --- a/src/main.py +++ b/src/main.py @@ -10,6 +10,7 @@ from logger import logger import logging import platform import application +import keys from mysc.thread_utils import call_threaded log = logging.getLogger("main") @@ -22,6 +23,7 @@ def setup(): sound.setup() output.setup() languageHandler.setLanguage(config.app["app-settings"]["language"]) + keys.setup() from controller import mainController from sessionmanager import sessionManager app = wx.App() diff --git a/src/sessionmanager/session.py b/src/sessionmanager/session.py index 29c868e6..80d1f10e 100644 --- a/src/sessionmanager/session.py +++ b/src/sessionmanager/session.py @@ -2,7 +2,7 @@ """ The main session object. Here are the twitter functions to interact with the "model" of TWBlue.""" import urllib2 import twitter -import application +from keys import keyring import session_exceptions as Exceptions import paths import output @@ -285,12 +285,12 @@ class Session(object): def get_main_stream(self): log.debug("Starting the main stream...") - self.main_stream = twitter.buffers.stream.streamer(application.app_key, application.app_secret, self.settings["twitter"]["user_key"], self.settings["twitter"]["user_secret"], self) + self.main_stream = twitter.buffers.stream.streamer(keyring.get("api_key"), keyring.get("api_secret"), self.settings["twitter"]["user_key"], self.settings["twitter"]["user_secret"], self) stream_threaded(self.main_stream.user, self.session_id) def get_timelines(self): log.debug("Starting the timelines stream...") - self.timelinesStream = twitter.buffers.indibidual.timelinesStreamer(application.app_key, application.app_secret, self.settings["twitter"]["user_key"], self.settings["twitter"]["user_secret"], session=self) + self.timelinesStream = twitter.buffers.indibidual.timelinesStreamer(keyring.get("api_key"), keyring.get("api_secret"), self.settings["twitter"]["user_key"], self.settings["twitter"]["user_secret"], session=self) ids = "" for i in self.settings["other_buffers"]["timelines"]: ids = ids + "%s, " % (self.db[i+"-timeline"][0]["user"]["id_str"]) diff --git a/src/twitter/twitter.py b/src/twitter/twitter.py index b27c77d6..cc45c6d9 100644 --- a/src/twitter/twitter.py +++ b/src/twitter/twitter.py @@ -2,24 +2,25 @@ import BaseHTTPServer import webbrowser from twython import Twython, TwythonError -import application +from keys import keyring import authorisationHandler + class twitter(object): def login(self, user_key, user_secret): - self.twitter = Twython(application.app_key, application.app_secret, user_key, user_secret) + self.twitter = Twython(keyring.get("api_key"), keyring.get("api_secret"), user_key, user_secret) self.credentials = self.twitter.verify_credentials() def authorise(self, settings): httpd = BaseHTTPServer.HTTPServer(('127.0.0.1', 8080), authorisationHandler.handler) - twitter = Twython(application.app_key, application.app_secret, auth_endpoint='authorize') + twitter = Twython(keyring.get("app_key"), keyring.get("app_secret"), auth_endpoint='authorize') auth = twitter.get_authentication_tokens("http://127.0.0.1:8080") webbrowser.open_new_tab(auth['auth_url']) # global logged, verifier while authorisationHandler.logged == False: httpd.handle_request() - self.twitter = Twython(application.app_key, application.app_secret, auth['oauth_token'], auth['oauth_token_secret']) + self.twitter = Twython(keyring.get("api_key"), keyring.get("api_secret"), auth['oauth_token'], auth['oauth_token_secret']) final = self.twitter.get_authorized_tokens(authorisationHandler.verifier) self.save_configuration(settings, final["oauth_token"], final["oauth_token_secret"])