Skip to content

Commit

Permalink
Porting code from liboauth - thanks to http://liboauth.sf.net/
Browse files Browse the repository at this point in the history
First tests using real Twitter API

Signed-off-by: Daniele Ricci <[email protected]>
  • Loading branch information
daniele-athome committed Nov 10, 2010
1 parent 73d1a6a commit 11a1880
Show file tree
Hide file tree
Showing 16 changed files with 1,675 additions and 18 deletions.
2 changes: 1 addition & 1 deletion autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ autoreconf -v --install || exit 1
#intltoolize -c --automake --force || exit 1
cd $ORIGDIR || exit $?

$srcdir/configure --enable-debug "$@"
$srcdir/configure --enable-debug --enable-nss "$@"
52 changes: 50 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AC_INIT([MicroTwitter], [0.1], [[email protected]], [microtwitter])
AC_INIT([Micromoko], [0.1], [[email protected]], [micromoko])
AC_CONFIG_SRCDIR(Makefile.am)
AC_CONFIG_HEADERS(config.h)
AC_CONFIG_MACRO_DIR([m4])
Expand All @@ -16,7 +16,8 @@ AM_GNU_GETTEXT_VERSION([0.12.1])
dnl Dependencies
ELEMENTARY_REQUIRED=0.0.0
GLIB_REQUIRED=2.18.0
MOKOSUITE_REQUIRED=$PACKAGE_VERSION
MOKOSUITE_REQUIRED=1.0.99
LIBSOUP_REQUIRED=2.30

PKG_CHECK_MODULES(GLIB,
glib-2.0 >= $GLIB_REQUIRED
Expand All @@ -32,6 +33,10 @@ PKG_CHECK_MODULES(MOKOSUITE,
mokosuite-ui >= $MOKOSUITE_REQUIRED
)

PKG_CHECK_MODULES(SOUP,
libsoup-2.4 >= $LIBSOUP_REQUIRED
)

AC_ARG_ENABLE(debug,
AC_HELP_STRING([--enable-debug], [Enable debug build (default: disabled)]),
enable_debug=$enableval,
Expand All @@ -43,12 +48,55 @@ fi

AC_SUBST(VERSION)

AH_TEMPLATE([USE_NSS], [Define to use NSS instead of OpenSSL])

AC_ARG_ENABLE(nss, AC_HELP_STRING([--enable-nss],[use NSS instead of OpenSSL]))

dnl ** crypto/hash lib (OpenSSL or NSS)
AS_IF([test "${enable_nss}" == "yes"], [
PKG_CHECK_MODULES(NSS, nss, [ AC_DEFINE(USE_NSS, 1) USE_NSS=1 PC_REQ="$PC_REQ nss" ])
HASH_LIBS=${NSS_LIBS}
HASH_CFLAGS=${NSS_CFLAGS}
report_hash="NSS"
], [
AC_CHECK_HEADERS(openssl/hmac.h)
if test -z "${HASH_LIBS}"; then
HASH_LIBS="-lcrypto"
fi
if test -z "${HASH_CFLAGS}"; then
HASH_CFLAGS=""
fi
report_hash="OpenSSL"
PC_LIB="$PC_LIB -lcrypto"
PC_REQ="$PC_REQ libcrypto"
AC_MSG_NOTICE([
NOTE: OpenSSL is not compatible with GPL applications.
Even if only linked with GPL code you are not allowed to distibute your app.
However liboauth provides an exeption (to the GPL) to circumvent this issue
(see README, src/hash.c). Nevertheless, double-check your licensing.
liboauth itself is licensed under MIT license and comatible with the GPL.
Either way, you are probably better off using NSS (configure --enable-nss);
future versions of liboauth will default to the Mozilla NSS.
see http://people.gnome.org/~markmc/openssl-and-the-gpl.html
])
])

AC_SUBST(HASH_LIBS)
AC_SUBST(HASH_CFLAGS)


EFL_WITH_BIN([edje], [edje-cc], [edje_cc])


AC_OUTPUT([
Makefile
src/Makefile
src/twitter/Makefile
src/twitter/oauth/Makefile
data/Makefile
data/themes/Makefile
data/themes/gry/Makefile
Expand Down
2 changes: 1 addition & 1 deletion data/themes/gry/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MAINTAINERCLEANFILES = Makefile.in

filesdir = $(datadir)/microtwitter/themes
filesdir = $(datadir)/micromoko/themes
files_DATA = gry.edj

EDC_DEPS =
Expand Down
9 changes: 6 additions & 3 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SUBDIRS = twitter

MAINTAINERCLEANFILES = Makefile.in

AM_CPPFLAGS = \
Expand All @@ -11,12 +13,13 @@ AM_CPPFLAGS = \
AM_LDFLAGS = \
@ELEMENTARY_LIBS@ \
@GLIB_LIBS@ \
@MOKOSUITE_LIBS@
@MOKOSUITE_LIBS@ \
-Ltwitter -ltwitter


bin_PROGRAMS = microtwitter
bin_PROGRAMS = micromoko

microtwitter_SOURCES = \
micromoko_SOURCES = \
globals.h \
main.c \
timeline.c \
Expand Down
4 changes: 2 additions & 2 deletions src/globals.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* MicroTwitter
* Micromoko
* Globals definitions
* Copyright (C) 2009-2010 Daniele Ricci <[email protected]>
*
Expand Down Expand Up @@ -42,7 +42,7 @@ extern int _log_dom;
#define LOG_LEVEL EINA_LOG_LEVEL_INFO
#endif

#define MICROTWITTER_DATADIR DATADIR "/microtwitter"
#define MICROMOKO_DATADIR DATADIR "/micromoko"

extern RemoteConfigService* home_config;

Expand Down
20 changes: 11 additions & 9 deletions src/main.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* MicroTwitter
* Micromoko
* Entry point
* Copyright (C) 2009-2010 Daniele Ricci <[email protected]>
*
Expand All @@ -26,9 +26,10 @@
#include <dbus/dbus-glib-bindings.h>

#include "globals.h"
#include "twitter/twitter.h"

#define MICROTWITTER_NAME "org.mokosuite.twitter"
#define MICROTWITTER_CONFIG_PATH MOKOSUITE_DBUS_PATH "/Twitter/Config"
#define MICROMOKO_NAME "org.mokosuite.micromoko"
#define MICROMOKO_CONFIG_PATH MOKOSUITE_DBUS_PATH "/Micromoko/Config"


// default log domain
Expand All @@ -51,27 +52,28 @@ int main(int argc, char* argv[])

EINA_LOG_INFO("%s version %s", PACKAGE_NAME, VERSION);

/* other things */
// glib integration
mokosuite_utils_init();
mokosuite_utils_glib_init(TRUE);
mokosuite_ui_init(argc, argv);

EINA_LOG_DBG("Loading data from %s", MICROTWITTER_DATADIR);
EINA_LOG_DBG("Loading data from %s", MICROMOKO_DATADIR);

// dbus name
DBusGConnection* session_bus = dbus_session_bus();
if (!session_bus || !dbus_request_name(session_bus, MICROTWITTER_NAME))
if (!session_bus || !dbus_request_name(session_bus, MICROMOKO_NAME))
return EXIT_FAILURE;

// config database
char* cfg_file = g_strdup_printf("%s/.config/%s/settings.conf", g_get_home_dir(), PACKAGE);
home_config = remote_config_service_new(session_bus,
MICROTWITTER_CONFIG_PATH,
MICROMOKO_CONFIG_PATH,
cfg_file);
g_free(cfg_file);

// twitter init
twitter_init(home_config);

elm_theme_extension_add(NULL, MICROTWITTER_DATADIR "/theme.edj");
elm_theme_extension_add(NULL, MICROMOKO_DATADIR "/theme.edj");
// TODO additional themes

// TODO public timeline or last open window?
Expand Down
25 changes: 25 additions & 0 deletions src/twitter/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
SUBDIRS = oauth

MAINTAINERCLEANFILES = Makefile.in

AM_CPPFLAGS = \
@MOKOSUITE_CFLAGS@ \
@GLIB_CFLAGS@ \
@SOUP_CFLAGS@ \
-Wall

AM_LDFLAGS = \
@GLIB_LIBS@ \
@MOKOSUITE_LIBS@ \
@SOUP_LIBS@ \
-lreadline
# !!!TEST TEST TEST!!!

noinst_LTLIBRARIES = libtwitter.la

libtwitter_la_SOURCES = \
private.h \
twitter.h \
twitter.c

libtwitter_la_LIBADD = -Loauth -loauth
21 changes: 21 additions & 0 deletions src/twitter/oauth/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MAINTAINERCLEANFILES = Makefile.in

AM_CPPFLAGS = \
@HASH_CFLAGS@ \
@SOUP_CFLAGS@ \
-DDATADIR=\""$(datadir)"\" \
-DLOCALEDIR=\"$(localedir)\" \
-Wall

AM_LDFLAGS = \
@HASH_LIBS@ \
@SOUP_LIBS@

noinst_LTLIBRARIES = liboauth.la

liboauth_la_SOURCES = \
oauth.c \
oauth.h \
encode.c \
encode.h \
hash.c
Loading

0 comments on commit 11a1880

Please sign in to comment.