Commit 9ad98cbd authored by Brahim Abes's avatar Brahim Abes

implement: accounts info to be read from config file

parent da4f2c00
......@@ -12,18 +12,32 @@
# cmake
# libwbxml (Not from Package Manager - use \\boudica\projects\INT07\Reference\Linux\libwbxml-0.11.beta4.tar.gz)
# the file accounts.cfg needs to be in your system configuration folder "/usr/local/etc"
# type the following command in your terminal:
#
# sudo cp ./eas-daemon/data/accounts.cfg /usr/local/etc
export GLIB_GENMARSHAL=glib-genmarshal
clear
make clean
./autogen.sh
aclocal
autoconf
autoheader
touch NEWS README AUTHORS ChangeLog
automake --add-missing
#mkdir $HOME/eas-daemon-install
#./configure $HOME/eas-daemon-install
./configure
make all
#make install
./eas-daemon/src/activesyncd &
#./eas-daemon/src/.libs/activesyncd &
make check
killall lt-activesyncd
......@@ -30,6 +30,7 @@ INCLUDES = -I/usr/include/libsoup-2.4 \
-I/usr/include/evolution-data-server-2.32
LIBS = -L/usr/lib \
-lsoup-2.4 \
......
......@@ -12,7 +12,7 @@ G_DEFINE_TYPE (EasAccounts, eas_accounts, G_TYPE_OBJECT);
struct _EasAccountsPrivate
{
gint64 accountId;
gchar serverUri[64];
gchar serverUri[128];
gchar username[64];
gchar password[64];
};
......@@ -80,21 +80,22 @@ eas_accounts_get_server_uri (EasAccounts* self, guint64 accountId)
int eas_accounts_read_accounts_info(EasAccounts* self)
{
g_debug("eas_accounts_read_accounts_info ++\n");
FILE *myfile =NULL;
myfile = fopen("../../eas-daemon/data/accounts.cfg","r");
if(myfile==NULL)
FILE *file =NULL;
file = fopen("/usr/local/etc/accounts.cfg","r");
if(file==NULL)
{
fprintf(stderr, "Can't open input file accounts.cfg!\n");
g_debug("Can't find config file - need to copy data/accounts.cfg to /usr/local/etc\n");
return 1;
}
int status = 0;
status = fscanf(myfile, "accountId=%lld\nserverUri=%s\nusername=%s\npassword=%s\n",
status = fscanf(file, "accountId=%lld\nserverUri=%s\nusername=%s\npassword=%s\n",
&self->_priv->accountId, self->_priv->serverUri, self->_priv->username, self->_priv->password);
if (status != 4)
{
g_debug(stderr, "Error reading data from file accounts.cfg!\n");
fclose (myfile);
g_debug("Error reading data from file accounts.cfg!\n");
fclose (file);
return 2;
}
......@@ -102,7 +103,7 @@ int eas_accounts_read_accounts_info(EasAccounts* self)
self->_priv->accountId, self->_priv->serverUri, self->_priv->username, self->_priv->password);
fclose (myfile);
fclose (file);
g_debug("eas_accounts_read_accounts_info --\n");
return 0;
}
......
......@@ -58,6 +58,7 @@ activesyncd_SOURCES = activesyncd-common-defs.h \
eas-contact.c \
eas-mail.h \
eas-mail.c
activesyncd_LDADD = ../libeas/libeas.la ../../libeasmail/src/libeasmail.la $(INTI_LIBS)
......
......@@ -36,6 +36,7 @@
int main(int argc, char** argv) {
DBusGConnection* bus = NULL;
DBusGProxy* busProxy = NULL;
EasAccounts* EasAccounts = NULL;
EasConnection* EasConnObj = NULL;
EasCalendar* EasCalendarObj = NULL;
EasCommon* EasCommonObj = NULL;
......@@ -56,29 +57,39 @@ int main(int argc, char** argv) {
}
//Creating all the GObjects
g_debug("Creating EEasConnection GObject.");
//EasConnObj = g_object_new(EAS_TYPE_CONNECTION , NULL);
g_debug("activesyncd Daemon Started");
GError* cnc_error = NULL;
EasAccounts* account = eas_accounts_new ();
g_print("eas_accounts_read_accounts_info\n");
int err = eas_accounts_read_accounts_info(account);
g_debug("creating acounts object\n");
EasAccounts = eas_accounts_new ();
g_debug("eas_accounts_read_accounts_info\n");
int err = eas_accounts_read_accounts_info(EasAccounts);
if (err !=0)
{
g_print("Error reading data from file accounts.cfg\n");
g_debug("Error reading data from file accounts.cfg\n");
g_main_loop_quit (mainloop);
exit(err);
}
g_print("getting data from EasAccounts object\n");
g_debug("getting data from EasAccounts object\n");
//TODO: handling mltiple connections (connections per account)
guint64 accountId;
accountId =1234567890;
gchar* username = eas_accounts_get_user_id (account, accountId);
gchar* password = eas_accounts_get_password (account, accountId);
gchar* serverUri = eas_accounts_get_server_uri (account, accountId);
gchar* serverUri = NULL;
gchar* username = NULL;
gchar* password = NULL;
//TODO: handling mltiple connections (connections per account)
serverUri = eas_accounts_get_server_uri (EasAccounts, accountId);
username = eas_accounts_get_user_id (EasAccounts, accountId);
password = eas_accounts_get_password (EasAccounts, accountId);
g_debug("Creating EEasConnection GObject.\n");
GError* cnc_error = NULL;
g_print("Creating EEasConnection GObject.\n");
//TODO: EasConnection -no need to pass this params, they are read form config file
EasConnObj = eas_connection_new(serverUri, username, password, &cnc_error);
if (EasConnObj == NULL) {
g_debug("Error: Failed to create EEasConnection instance");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment