mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 11:18:08 -06:00
A new library for storing app keys is added
This commit is contained in:
parent
2a7e09b166
commit
62b0bc76a8
23
mysc/keys/api_keys.c
Normal file
23
mysc/keys/api_keys.c
Normal file
@ -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";
|
||||
}
|
||||
|
12
mysc/keys/api_keys.h
Normal file
12
mysc/keys/api_keys.h
Normal file
@ -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
|
@ -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'
|
@ -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)
|
||||
|
@ -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):
|
||||
|
29
src/keys/__init__.py
Normal file
29
src/keys/__init__.py
Normal file
@ -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)
|
BIN
src/keys/lib/api_keys32.dll
Normal file
BIN
src/keys/lib/api_keys32.dll
Normal file
Binary file not shown.
@ -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()
|
||||
|
@ -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"])
|
||||
|
@ -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"])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user