Merge branch '14-update-delta' into 'master'
Update to deltachat-core v0.35.0 Closes #14 See merge request lupine/purple-plugin-delta!6
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -1,2 +1,2 @@
|
|||||||
vendor/libetpan-1.8.tar.gz filter=lfs diff=lfs merge=lfs -text
|
vendor/libetpan-1.8.tar.gz filter=lfs diff=lfs merge=lfs -text
|
||||||
vendor/deltachat-core-master.tar.gz filter=lfs diff=lfs merge=lfs -text
|
vendor/deltachat-core-0.35.0.tar.gz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -2,5 +2,5 @@
|
|||||||
/libetpan.so
|
/libetpan.so
|
||||||
/libdeltachat.so
|
/libdeltachat.so
|
||||||
/libnetpgp.so
|
/libnetpgp.so
|
||||||
/vendor/deltachat-core-master
|
/vendor/deltachat-core-0.35.0
|
||||||
/vendor/libetpan-1.8
|
/vendor/libetpan-1.8
|
||||||
|
@@ -3,25 +3,24 @@ Debian 9:
|
|||||||
stage: build
|
stage: build
|
||||||
image: debian:stretch
|
image: debian:stretch
|
||||||
script:
|
script:
|
||||||
|
# deltachat-core needs a later version of meson, fortunately it's in stretch-backports
|
||||||
|
- echo 'deb http://httpredir.debian.org/debian/ stretch-backports main' > /etc/apt/sources.list.d/stretch-backports.list
|
||||||
- apt update
|
- apt update
|
||||||
# libetpan
|
# libetpan
|
||||||
# FIXME: libetpan 1.16 is available in Debian, but we need 1.17+: https://github.com/deltachat/deltachat-core/issues/157
|
# FIXME: libetpan 1.16 is available in Debian, but we need 1.17+: https://github.com/deltachat/deltachat-core/issues/157
|
||||||
# TODO: it can take libcurl as well. Do we need it?
|
- apt install --no-install-recommends -yy -t stretch-backports build-essential autoconf automake libtool libdb-dev libexpat1-dev libsasl2-dev libssl1.0-dev
|
||||||
- apt install --no-install-recommends -yy build-essential autoconf automake libtool libdb-dev libexpat1-dev libsasl2-dev libssl1.0-dev
|
|
||||||
- cd vendor && tar -xvzf libetpan-1.8.tar.gz && cd libetpan-1.8 && ./autogen.sh && ./configure && make && make install && cd ../..
|
- cd vendor && tar -xvzf libetpan-1.8.tar.gz && cd libetpan-1.8 && ./autogen.sh && ./configure && make && make install && cd ../..
|
||||||
- cp /usr/local/lib/libetpan.so libetpan.so
|
- cp /usr/local/lib/libetpan.so libetpan.so
|
||||||
# deltachat-core
|
# deltachat-core
|
||||||
- apt install --no-install-recommends -yy meson ninja-build pkg-config zlib1g-dev libsqlite3-dev libsasl2-dev libssl1.0-dev libbz2-dev
|
- apt install --no-install-recommends -t stretch-backports -yy meson ninja-build pkg-config zlib1g-dev liblockfile-dev libsqlite3-dev libsasl2-dev libssl1.0-dev libbz2-dev
|
||||||
- cd vendor && tar -xvzf deltachat-core-master.tar.gz && cd deltachat-core-master && mkdir builddir && cd builddir && meson && ninja && ninja install && cd ../../..
|
- cd vendor && tar -xvzf deltachat-core-0.35.0.tar.gz && cd deltachat-core-0.35.0 && mkdir builddir && cd builddir && meson && ninja && ninja install && cd ../../..
|
||||||
- cp /usr/local/lib/x86_64-linux-gnu/libdeltachat.so libdeltachat.so
|
- cp /usr/local/lib/x86_64-linux-gnu/libdeltachat.so libdeltachat.so
|
||||||
- cp /usr/local/lib/x86_64-linux-gnu/libnetpgp.so libnetpgp.so
|
|
||||||
# purple-plugin-delta
|
# purple-plugin-delta
|
||||||
- apt install --no-install-recommends -yy libpurple-dev libcurl4-openssl-dev libglib2.0-dev
|
- apt install --no-install-recommends -t stretch-backports -yy libpurple-dev libcurl4-openssl-dev libglib2.0-dev
|
||||||
- make
|
- make
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- libetpan.so
|
- libetpan.so
|
||||||
- libdeltachat.so
|
- libdeltachat.so
|
||||||
- libnetpgp.so
|
|
||||||
- libdelta.so
|
- libdelta.so
|
||||||
|
|
||||||
|
@@ -3,8 +3,7 @@
|
|||||||
#include <util.h>
|
#include <util.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <pthread.h>
|
||||||
#include <deltachat/mrmailbox.h>
|
|
||||||
|
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include <curl/easy.h>
|
#include <curl/easy.h>
|
||||||
@@ -15,8 +14,40 @@
|
|||||||
|
|
||||||
void delta_recv_im(DeltaConnectionData *conn, uint32_t msg_id);
|
void delta_recv_im(DeltaConnectionData *conn, uint32_t msg_id);
|
||||||
|
|
||||||
|
void *imap_thread_func(void *delta_connection_data)
|
||||||
|
{
|
||||||
|
DeltaConnectionData *conn = (DeltaConnectionData *)delta_connection_data;
|
||||||
|
g_assert(conn != NULL);
|
||||||
|
|
||||||
|
dc_context_t *mailbox = conn->mailbox;
|
||||||
|
g_assert(mailbox != NULL);
|
||||||
|
|
||||||
|
while (conn->runthreads) {
|
||||||
|
dc_perform_imap_jobs(mailbox);
|
||||||
|
dc_perform_imap_fetch(mailbox);
|
||||||
|
dc_perform_imap_idle(mailbox);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
void *smtp_thread_func(void *delta_connection_data)
|
||||||
|
{
|
||||||
|
DeltaConnectionData *conn = (DeltaConnectionData *)delta_connection_data;
|
||||||
|
g_assert(conn != NULL);
|
||||||
|
|
||||||
|
dc_context_t *mailbox = conn->mailbox;
|
||||||
|
g_assert(mailbox != NULL);
|
||||||
|
|
||||||
|
while (conn->runthreads) {
|
||||||
|
dc_perform_smtp_jobs(mailbox);
|
||||||
|
dc_perform_smtp_idle(mailbox);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_transpose_config(mrmailbox_t *mailbox, PurpleAccount *acct)
|
_transpose_config(dc_context_t *mailbox, PurpleAccount *acct)
|
||||||
{
|
{
|
||||||
const char *addr = acct->username;
|
const char *addr = acct->username;
|
||||||
const char *display = purple_account_get_string(acct, PLUGIN_ACCOUNT_OPT_DISPLAY_NAME, NULL);
|
const char *display = purple_account_get_string(acct, PLUGIN_ACCOUNT_OPT_DISPLAY_NAME, NULL);
|
||||||
@@ -24,25 +55,25 @@ _transpose_config(mrmailbox_t *mailbox, PurpleAccount *acct)
|
|||||||
const char *imap_host = purple_account_get_string(acct, PLUGIN_ACCOUNT_OPT_IMAP_SERVER_HOST, NULL);
|
const char *imap_host = purple_account_get_string(acct, PLUGIN_ACCOUNT_OPT_IMAP_SERVER_HOST, NULL);
|
||||||
const char *imap_user = purple_account_get_string(acct, PLUGIN_ACCOUNT_OPT_IMAP_USER, NULL);
|
const char *imap_user = purple_account_get_string(acct, PLUGIN_ACCOUNT_OPT_IMAP_USER, NULL);
|
||||||
const char *imap_pass = purple_account_get_password(acct);
|
const char *imap_pass = purple_account_get_password(acct);
|
||||||
int imap_port = purple_account_get_int(acct, PLUGIN_ACCOUNT_OPT_IMAP_SERVER_PORT, DEFAULT_IMAP_PORT);
|
const char *imap_port = purple_account_get_string(acct, PLUGIN_ACCOUNT_OPT_IMAP_SERVER_PORT, NULL);
|
||||||
|
|
||||||
const char *smtp_host = purple_account_get_string(acct, PLUGIN_ACCOUNT_OPT_SMTP_SERVER_HOST, NULL);
|
const char *smtp_host = purple_account_get_string(acct, PLUGIN_ACCOUNT_OPT_SMTP_SERVER_HOST, NULL);
|
||||||
const char *smtp_user = purple_account_get_string(acct, PLUGIN_ACCOUNT_OPT_SMTP_USER, NULL);
|
const char *smtp_user = purple_account_get_string(acct, PLUGIN_ACCOUNT_OPT_SMTP_USER, NULL);
|
||||||
const char *smtp_pass = purple_account_get_string(acct, PLUGIN_ACCOUNT_OPT_SMTP_PASS, NULL);
|
const char *smtp_pass = purple_account_get_string(acct, PLUGIN_ACCOUNT_OPT_SMTP_PASS, NULL);
|
||||||
int smtp_port = purple_account_get_int(acct, PLUGIN_ACCOUNT_OPT_SMTP_SERVER_PORT, DEFAULT_SMTP_PORT);
|
const char *smtp_port = purple_account_get_string(acct, PLUGIN_ACCOUNT_OPT_SMTP_SERVER_PORT, NULL);
|
||||||
|
|
||||||
mrmailbox_set_config(mailbox, PLUGIN_ACCOUNT_OPT_ADDR, addr);
|
dc_set_config(mailbox, PLUGIN_ACCOUNT_OPT_ADDR, addr);
|
||||||
mrmailbox_set_config(mailbox, PLUGIN_ACCOUNT_OPT_DISPLAY_NAME, display);
|
dc_set_config(mailbox, PLUGIN_ACCOUNT_OPT_DISPLAY_NAME, display);
|
||||||
|
|
||||||
mrmailbox_set_config(mailbox, PLUGIN_ACCOUNT_OPT_IMAP_SERVER_HOST, imap_host);
|
dc_set_config(mailbox, PLUGIN_ACCOUNT_OPT_IMAP_SERVER_HOST, imap_host);
|
||||||
mrmailbox_set_config(mailbox, PLUGIN_ACCOUNT_OPT_IMAP_USER, imap_user);
|
dc_set_config(mailbox, PLUGIN_ACCOUNT_OPT_IMAP_USER, imap_user);
|
||||||
mrmailbox_set_config(mailbox, PLUGIN_ACCOUNT_OPT_IMAP_PASS, imap_pass);
|
dc_set_config(mailbox, PLUGIN_ACCOUNT_OPT_IMAP_PASS, imap_pass);
|
||||||
mrmailbox_set_config_int(mailbox, PLUGIN_ACCOUNT_OPT_IMAP_SERVER_PORT, imap_port);
|
dc_set_config(mailbox, PLUGIN_ACCOUNT_OPT_IMAP_SERVER_PORT, imap_port);
|
||||||
|
|
||||||
mrmailbox_set_config(mailbox, PLUGIN_ACCOUNT_OPT_SMTP_SERVER_HOST, smtp_host);
|
dc_set_config(mailbox, PLUGIN_ACCOUNT_OPT_SMTP_SERVER_HOST, smtp_host);
|
||||||
mrmailbox_set_config(mailbox, PLUGIN_ACCOUNT_OPT_SMTP_USER, smtp_user);
|
dc_set_config(mailbox, PLUGIN_ACCOUNT_OPT_SMTP_USER, smtp_user);
|
||||||
mrmailbox_set_config(mailbox, PLUGIN_ACCOUNT_OPT_SMTP_PASS, smtp_pass);
|
dc_set_config(mailbox, PLUGIN_ACCOUNT_OPT_SMTP_PASS, smtp_pass);
|
||||||
mrmailbox_set_config_int(mailbox, PLUGIN_ACCOUNT_OPT_SMTP_SERVER_PORT, smtp_port);
|
dc_set_config(mailbox, PLUGIN_ACCOUNT_OPT_SMTP_SERVER_PORT, smtp_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This and WriteMemoryCallback are "borrowed" from https://curl.haxx.se/libcurl/c/getinmemory.html
|
// This and WriteMemoryCallback are "borrowed" from https://curl.haxx.se/libcurl/c/getinmemory.html
|
||||||
@@ -135,14 +166,14 @@ delta_process(void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
delta_fresh_messages(DeltaConnectionData *conn, mrmailbox_t *mailbox)
|
delta_fresh_messages(DeltaConnectionData *conn, dc_context_t *mailbox)
|
||||||
{
|
{
|
||||||
g_assert(conn != NULL);
|
g_assert(conn != NULL);
|
||||||
g_assert(mailbox != NULL);
|
g_assert(mailbox != NULL);
|
||||||
|
|
||||||
// Spot any messages received while offline
|
// Spot any messages received while offline
|
||||||
mrarray_t *fresh_msgs = mrmailbox_get_fresh_msgs(mailbox);
|
dc_array_t *fresh_msgs = dc_get_fresh_msgs(mailbox);
|
||||||
size_t fresh_count = mrarray_get_cnt(fresh_msgs);
|
size_t fresh_count = dc_array_get_cnt(fresh_msgs);
|
||||||
|
|
||||||
printf("*** fresh_count: %zu\n", fresh_count);
|
printf("*** fresh_count: %zu\n", fresh_count);
|
||||||
|
|
||||||
@@ -151,7 +182,7 @@ delta_fresh_messages(DeltaConnectionData *conn, mrmailbox_t *mailbox)
|
|||||||
g_assert(pr != NULL);
|
g_assert(pr != NULL);
|
||||||
|
|
||||||
pr->conn = conn;
|
pr->conn = conn;
|
||||||
pr->msg_id = mrarray_get_id(fresh_msgs, i);
|
pr->msg_id = dc_array_get_id(fresh_msgs, i);
|
||||||
|
|
||||||
purple_timeout_add(0, delta_process, pr);
|
purple_timeout_add(0, delta_process, pr);
|
||||||
}
|
}
|
||||||
@@ -165,9 +196,9 @@ delta_fresh_messages(DeltaConnectionData *conn, mrmailbox_t *mailbox)
|
|||||||
// events may be dispatched from any delta thread. Use
|
// events may be dispatched from any delta thread. Use
|
||||||
// purple_timeout_add(0, callback, data) to run on the main thread instead
|
// purple_timeout_add(0, callback, data) to run on the main thread instead
|
||||||
uintptr_t
|
uintptr_t
|
||||||
my_delta_handler(mrmailbox_t* mailbox, int event, uintptr_t data1, uintptr_t data2)
|
my_delta_handler(dc_context_t* mailbox, int event, uintptr_t data1, uintptr_t data2)
|
||||||
{
|
{
|
||||||
DeltaConnectionData *conn = (DeltaConnectionData *)mrmailbox_get_userdata(mailbox);
|
DeltaConnectionData *conn = (DeltaConnectionData *)dc_get_userdata(mailbox);
|
||||||
g_assert(conn != NULL);
|
g_assert(conn != NULL);
|
||||||
|
|
||||||
ProcessRequest *pr;
|
ProcessRequest *pr;
|
||||||
@@ -176,21 +207,25 @@ my_delta_handler(mrmailbox_t* mailbox, int event, uintptr_t data1, uintptr_t dat
|
|||||||
printf("my_delta_handler(mailbox, %d, %lu, %lu)\n", event, data1, data2);
|
printf("my_delta_handler(mailbox, %d, %lu, %lu)\n", event, data1, data2);
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case MR_EVENT_INFO:
|
case DC_EVENT_SMTP_MESSAGE_SENT:
|
||||||
|
case DC_EVENT_IMAP_CONNECTED:
|
||||||
|
case DC_EVENT_SMTP_CONNECTED:
|
||||||
|
case DC_EVENT_INFO:
|
||||||
printf("INFO: %s\n", (char *)data2);
|
printf("INFO: %s\n", (char *)data2);
|
||||||
break;
|
break;
|
||||||
case MR_EVENT_WARNING:
|
case DC_EVENT_WARNING:
|
||||||
printf("WARNING: %s\n", (char *)data2);
|
printf("WARNING: %s\n", (char *)data2);
|
||||||
break;
|
break;
|
||||||
case MR_EVENT_ERROR:
|
case DC_EVENT_ERROR:
|
||||||
|
case DC_EVENT_ERROR_NETWORK:
|
||||||
printf("ERROR: %d: %s\n", (int)data1, (char *)data2);
|
printf("ERROR: %d: %s\n", (int)data1, (char *)data2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MR_EVENT_MSGS_CHANGED:
|
case DC_EVENT_MSGS_CHANGED:
|
||||||
delta_fresh_messages(conn, mailbox);
|
delta_fresh_messages(conn, mailbox);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MR_EVENT_INCOMING_MSG:
|
case DC_EVENT_INCOMING_MSG:
|
||||||
// data1 is chat_id, which we don't seem to need yet.
|
// data1 is chat_id, which we don't seem to need yet.
|
||||||
// TODO: It may be needed for group chats
|
// TODO: It may be needed for group chats
|
||||||
pr = g_malloc(sizeof(ProcessRequest));
|
pr = g_malloc(sizeof(ProcessRequest));
|
||||||
@@ -202,21 +237,24 @@ my_delta_handler(mrmailbox_t* mailbox, int event, uintptr_t data1, uintptr_t dat
|
|||||||
|
|
||||||
// These are all to do with sending & receiving messages. The real meat of
|
// These are all to do with sending & receiving messages. The real meat of
|
||||||
// the event loop
|
// the event loop
|
||||||
case MR_EVENT_MSG_DELIVERED:
|
case DC_EVENT_MSG_DELIVERED:
|
||||||
case MR_EVENT_MSG_READ:
|
case DC_EVENT_MSG_READ:
|
||||||
case MR_EVENT_CHAT_MODIFIED:
|
case DC_EVENT_CHAT_MODIFIED:
|
||||||
case MR_EVENT_CONTACTS_CHANGED:
|
case DC_EVENT_CONTACTS_CHANGED:
|
||||||
debug("TODO!\n");
|
debug("TODO!\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MR_EVENT_CONFIGURE_PROGRESS:
|
case DC_EVENT_CONFIGURE_PROGRESS:
|
||||||
purple_connection_update_progress(conn->pc, "Connecting...", (int)data1, MAX_DELTA_CONFIGURE);
|
purple_connection_update_progress(conn->pc, "Connecting...", (int)data1, MAX_DELTA_CONFIGURE);
|
||||||
|
if ((int)data1 == MAX_DELTA_CONFIGURE) {
|
||||||
|
purple_connection_set_state(conn->pc, PURPLE_CONNECTED);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case MR_EVENT_HTTP_GET:
|
case DC_EVENT_HTTP_GET:
|
||||||
printf("HTTP GET requested: %s\n", (char *)data1);
|
printf("HTTP GET requested: %s\n", (char *)data1);
|
||||||
out = _http_get((char *)data1);
|
out = _http_get((char *)data1);
|
||||||
break;
|
break;
|
||||||
case MR_EVENT_IS_OFFLINE:
|
case DC_EVENT_IS_OFFLINE:
|
||||||
if ( conn->pc == NULL || !PURPLE_CONNECTION_IS_CONNECTED(conn->pc) ) {
|
if ( conn->pc == NULL || !PURPLE_CONNECTION_IS_CONNECTED(conn->pc) ) {
|
||||||
debug("Telling Delta we are offline\n");
|
debug("Telling Delta we are offline\n");
|
||||||
out = 1;
|
out = 1;
|
||||||
@@ -224,9 +262,7 @@ my_delta_handler(mrmailbox_t* mailbox, int event, uintptr_t data1, uintptr_t dat
|
|||||||
debug("Telling Delta we are online\n");
|
debug("Telling Delta we are online\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MR_EVENT_GET_STRING:
|
case DC_EVENT_GET_STRING:
|
||||||
case MR_EVENT_GET_QUANTITY_STRING:
|
|
||||||
case MR_EVENT_WAKE_LOCK:
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("Unknown event: %d\n", event);
|
printf("Unknown event: %d\n", event);
|
||||||
@@ -254,14 +290,25 @@ delta_connection_free(PurpleConnection *pc)
|
|||||||
|
|
||||||
g_assert(conn != NULL);
|
g_assert(conn != NULL);
|
||||||
|
|
||||||
purple_connection_set_protocol_data(pc, NULL);
|
conn->runthreads = 0;
|
||||||
|
|
||||||
if (conn->mailbox != NULL) {
|
if (conn->mailbox != NULL) {
|
||||||
mrmailbox_stop_ongoing_process(conn->mailbox);
|
dc_maybe_network(conn->mailbox);
|
||||||
mrmailbox_disconnect(conn->mailbox);
|
|
||||||
mrmailbox_close(conn->mailbox);
|
// TODO: correctly handle join failing
|
||||||
mrmailbox_unref(conn->mailbox);
|
if (pthread_join(conn->imap_thread, NULL) != 0) {
|
||||||
|
debug("joining imap thread failed!\n");
|
||||||
}
|
}
|
||||||
|
if (pthread_join(conn->smtp_thread, NULL) != 0) {
|
||||||
|
debug("joining smtp thread failed!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
dc_stop_ongoing_process(conn->mailbox);
|
||||||
|
dc_close(conn->mailbox);
|
||||||
|
dc_context_unref(conn->mailbox);
|
||||||
|
}
|
||||||
|
|
||||||
|
purple_connection_set_protocol_data(pc, NULL);
|
||||||
|
|
||||||
// TODO: free resources as they are added to DeltaConnectionData
|
// TODO: free resources as they are added to DeltaConnectionData
|
||||||
conn->pc = NULL;
|
conn->pc = NULL;
|
||||||
@@ -276,37 +323,34 @@ delta_connection_start_login(PurpleConnection *pc)
|
|||||||
char dbname[1024];
|
char dbname[1024];
|
||||||
PurpleAccount *acct = pc->account;
|
PurpleAccount *acct = pc->account;
|
||||||
DeltaConnectionData *conn = purple_connection_get_protocol_data(pc);
|
DeltaConnectionData *conn = purple_connection_get_protocol_data(pc);
|
||||||
mrmailbox_t *mailbox = mrmailbox_new(my_delta_handler, conn, NULL);
|
dc_context_t *mailbox = dc_context_new(my_delta_handler, conn, NULL);
|
||||||
|
|
||||||
g_snprintf(
|
g_snprintf(
|
||||||
dbname, 1024, "%s%sdelta_db-%s",
|
dbname, 1024, "%s%sdelta_db-%s",
|
||||||
purple_user_dir(), G_DIR_SEPARATOR_S, acct->username
|
purple_user_dir(), G_DIR_SEPARATOR_S, acct->username
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!mrmailbox_open(mailbox, dbname, NULL)) {
|
if (!dc_open(mailbox, dbname, NULL)) {
|
||||||
debug("mrmailbox_open returned false...?\n");
|
debug("dc_open returned false...?\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
conn->mailbox = mailbox;
|
conn->mailbox = mailbox;
|
||||||
|
|
||||||
_transpose_config(mailbox, acct);
|
_transpose_config(mailbox, acct);
|
||||||
|
|
||||||
|
conn->runthreads = 1;
|
||||||
|
pthread_create(&conn->imap_thread, NULL, imap_thread_func, conn);
|
||||||
|
pthread_create(&conn->smtp_thread, NULL, smtp_thread_func, conn);
|
||||||
|
|
||||||
purple_connection_set_state(pc, PURPLE_CONNECTING);
|
purple_connection_set_state(pc, PURPLE_CONNECTING);
|
||||||
purple_connection_update_progress(pc, "Connecting...", 1, MAX_DELTA_CONFIGURE);
|
purple_connection_update_progress(pc, "Connecting...", 1, MAX_DELTA_CONFIGURE);
|
||||||
|
|
||||||
if (mrmailbox_is_configured(mailbox)) {
|
if (dc_is_configured(mailbox)) {
|
||||||
mrmailbox_connect(mailbox);
|
purple_connection_set_state(conn->pc, PURPLE_CONNECTED);
|
||||||
} else if (!mrmailbox_configure_and_connect(mailbox)) {
|
} else {
|
||||||
char *info = mrmailbox_get_info(mailbox);
|
dc_configure(mailbox);
|
||||||
debug(info);
|
|
||||||
g_free(info);
|
|
||||||
|
|
||||||
purple_connection_error(pc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR);
|
|
||||||
purple_connection_set_state(pc, PURPLE_DISCONNECTED);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
purple_connection_set_state(pc, PURPLE_CONNECTED);
|
dc_maybe_network(mailbox);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -319,44 +363,44 @@ delta_send_im(PurpleConnection *pc, const char *who, const char *message, Purple
|
|||||||
DeltaConnectionData *conn = (DeltaConnectionData *)purple_connection_get_protocol_data(pc);
|
DeltaConnectionData *conn = (DeltaConnectionData *)purple_connection_get_protocol_data(pc);
|
||||||
g_assert(conn != NULL);
|
g_assert(conn != NULL);
|
||||||
|
|
||||||
mrmailbox_t *mailbox = conn->mailbox;
|
dc_context_t *mailbox = conn->mailbox;
|
||||||
g_assert(mailbox != NULL);
|
g_assert(mailbox != NULL);
|
||||||
|
|
||||||
uint32_t contact_id = mrmailbox_create_contact(mailbox, NULL, who);
|
uint32_t contact_id = dc_create_contact(mailbox, NULL, who);
|
||||||
uint32_t chat_id = mrmailbox_create_chat_by_contact_id(mailbox, contact_id);
|
uint32_t chat_id = dc_create_chat_by_contact_id(mailbox, contact_id);
|
||||||
|
|
||||||
mrmailbox_send_text_msg(mailbox, chat_id, message);
|
dc_send_text_msg(mailbox, chat_id, message);
|
||||||
return 1; // success; echo the message to the chat window
|
return 1; // success; echo the message to the chat window
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
delta_recv_im(DeltaConnectionData *conn, uint32_t msg_id)
|
delta_recv_im(DeltaConnectionData *conn, uint32_t msg_id)
|
||||||
{
|
{
|
||||||
mrmailbox_t *mailbox = conn->mailbox;
|
dc_context_t *mailbox = conn->mailbox;
|
||||||
g_assert(mailbox != NULL);
|
g_assert(mailbox != NULL);
|
||||||
|
|
||||||
PurpleConnection *pc = conn->pc;
|
PurpleConnection *pc = conn->pc;
|
||||||
g_assert(pc != NULL);
|
g_assert(pc != NULL);
|
||||||
|
|
||||||
mrmsg_t* msg = mrmailbox_get_msg(mailbox, msg_id);
|
dc_msg_t* msg = dc_get_msg(mailbox, msg_id);
|
||||||
|
|
||||||
time_t timestamp = mrmsg_get_timestamp(msg);
|
time_t timestamp = dc_msg_get_timestamp(msg);
|
||||||
char *text = mrmsg_get_text(msg);
|
char *text = dc_msg_get_text(msg);
|
||||||
uint32_t contact_id = mrmsg_get_from_id(msg);
|
uint32_t contact_id = dc_msg_get_from_id(msg);
|
||||||
|
|
||||||
mrcontact_t *contact = mrmailbox_get_contact(mailbox, contact_id);
|
dc_contact_t *contact = dc_get_contact(mailbox, contact_id);
|
||||||
if (contact == NULL) {
|
if (contact == NULL) {
|
||||||
debug("Unknown contact! FIXME!\n");
|
debug("Unknown contact! FIXME!\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *who = mrcontact_get_addr(contact);
|
char *who = dc_contact_get_addr(contact);
|
||||||
|
|
||||||
serv_got_im(pc, who, text, PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_RAW, timestamp);
|
serv_got_im(pc, who, text, PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_RAW, timestamp);
|
||||||
|
|
||||||
mrmailbox_markseen_msgs(mailbox, &msg_id, 1);
|
dc_markseen_msgs(mailbox, &msg_id, 1);
|
||||||
g_free(who);
|
g_free(who);
|
||||||
out:
|
out:
|
||||||
g_free(text);
|
g_free(text);
|
||||||
mrmsg_unref(msg);
|
dc_msg_unref(msg);
|
||||||
}
|
}
|
||||||
|
@@ -2,16 +2,23 @@
|
|||||||
#define DELTA_CONNECTION_H
|
#define DELTA_CONNECTION_H
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <deltachat/deltachat.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
struct _PurpleConnection;
|
struct _PurpleConnection;
|
||||||
struct _mrmailbox;
|
|
||||||
|
|
||||||
typedef struct _DeltaConnectionData {
|
typedef struct _DeltaConnectionData {
|
||||||
struct _PurpleConnection *pc;
|
struct _PurpleConnection *pc;
|
||||||
struct _mrmailbox *mailbox;
|
dc_context_t *mailbox;
|
||||||
|
|
||||||
|
// Set to 0 to convince threads to exit
|
||||||
|
int runthreads;
|
||||||
|
|
||||||
|
pthread_t imap_thread;
|
||||||
|
pthread_t smtp_thread;
|
||||||
} DeltaConnectionData;
|
} DeltaConnectionData;
|
||||||
|
|
||||||
#define MAX_DELTA_CONFIGURE 901
|
#define MAX_DELTA_CONFIGURE 1000
|
||||||
|
|
||||||
void delta_connection_new(struct _PurpleConnection *pc);
|
void delta_connection_new(struct _PurpleConnection *pc);
|
||||||
void delta_connection_free(struct _PurpleConnection *pc);
|
void delta_connection_free(struct _PurpleConnection *pc);
|
||||||
|
10
libdelta.c
10
libdelta.c
@@ -72,12 +72,6 @@ pwd_opt(const char *text, const char *name, const char *def)
|
|||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PurpleAccountOption *
|
|
||||||
int_opt(const char *text, const char *name, int def)
|
|
||||||
{
|
|
||||||
return purple_account_option_int_new(text, name, def);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
delta_init_plugin(PurplePlugin *plugin)
|
delta_init_plugin(PurplePlugin *plugin)
|
||||||
{
|
{
|
||||||
@@ -89,7 +83,7 @@ delta_init_plugin(PurplePlugin *plugin)
|
|||||||
opts = g_list_prepend(opts, str_opt("Display Name", PLUGIN_ACCOUNT_OPT_DISPLAY_NAME, NULL));
|
opts = g_list_prepend(opts, str_opt("Display Name", PLUGIN_ACCOUNT_OPT_DISPLAY_NAME, NULL));
|
||||||
|
|
||||||
opts = g_list_prepend(opts, str_opt("IMAP Server Host", PLUGIN_ACCOUNT_OPT_IMAP_SERVER_HOST, NULL));
|
opts = g_list_prepend(opts, str_opt("IMAP Server Host", PLUGIN_ACCOUNT_OPT_IMAP_SERVER_HOST, NULL));
|
||||||
opts = g_list_prepend(opts, int_opt("IMAP Server Port", PLUGIN_ACCOUNT_OPT_IMAP_SERVER_PORT, DEFAULT_IMAP_PORT));
|
opts = g_list_prepend(opts, str_opt("IMAP Server Port", PLUGIN_ACCOUNT_OPT_IMAP_SERVER_PORT, NULL));
|
||||||
opts = g_list_prepend(opts, str_opt("IMAP Username", PLUGIN_ACCOUNT_OPT_IMAP_USER, NULL));
|
opts = g_list_prepend(opts, str_opt("IMAP Username", PLUGIN_ACCOUNT_OPT_IMAP_USER, NULL));
|
||||||
|
|
||||||
|
|
||||||
@@ -99,7 +93,7 @@ delta_init_plugin(PurplePlugin *plugin)
|
|||||||
// opts = g_list_prepend(opts, pwd_opt("IMAP Password", PLUGIN_ACCOUNT_OPT_IMAP_PASS, ""));
|
// opts = g_list_prepend(opts, pwd_opt("IMAP Password", PLUGIN_ACCOUNT_OPT_IMAP_PASS, ""));
|
||||||
|
|
||||||
opts = g_list_prepend(opts, str_opt("SMTP Server Host", PLUGIN_ACCOUNT_OPT_SMTP_SERVER_HOST, NULL));
|
opts = g_list_prepend(opts, str_opt("SMTP Server Host", PLUGIN_ACCOUNT_OPT_SMTP_SERVER_HOST, NULL));
|
||||||
opts = g_list_prepend(opts, int_opt("SMTP Server Port", PLUGIN_ACCOUNT_OPT_SMTP_SERVER_PORT, DEFAULT_SMTP_PORT));
|
opts = g_list_prepend(opts, str_opt("SMTP Server Port", PLUGIN_ACCOUNT_OPT_SMTP_SERVER_PORT, NULL));
|
||||||
opts = g_list_prepend(opts, str_opt("SMTP Username", PLUGIN_ACCOUNT_OPT_SMTP_USER, NULL));
|
opts = g_list_prepend(opts, str_opt("SMTP Username", PLUGIN_ACCOUNT_OPT_SMTP_USER, NULL));
|
||||||
opts = g_list_prepend(opts, pwd_opt("SMTP Password", PLUGIN_ACCOUNT_OPT_SMTP_PASS, NULL));
|
opts = g_list_prepend(opts, pwd_opt("SMTP Password", PLUGIN_ACCOUNT_OPT_SMTP_PASS, NULL));
|
||||||
|
|
||||||
|
@@ -10,10 +10,6 @@
|
|||||||
OPT_PROTO_CHAT_TOPIC | \
|
OPT_PROTO_CHAT_TOPIC | \
|
||||||
OPT_PROTO_IM_IMAGE
|
OPT_PROTO_IM_IMAGE
|
||||||
|
|
||||||
#define DEFAULT_SMTP_PORT 0
|
|
||||||
#define DEFAULT_IMAP_PORT 0
|
|
||||||
|
|
||||||
|
|
||||||
// These two will instead be the pidgin "username" and "password" options that
|
// These two will instead be the pidgin "username" and "password" options that
|
||||||
// I can't seem to get rid of.
|
// I can't seem to get rid of.
|
||||||
#define PLUGIN_ACCOUNT_OPT_ADDR "addr"
|
#define PLUGIN_ACCOUNT_OPT_ADDR "addr"
|
||||||
|
BIN
vendor/deltachat-core-0.35.0.tar.gz
(Stored with Git LFS)
vendored
Normal file
BIN
vendor/deltachat-core-0.35.0.tar.gz
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
BIN
vendor/deltachat-core-master.tar.gz
(Stored with Git LFS)
vendored
BIN
vendor/deltachat-core-master.tar.gz
(Stored with Git LFS)
vendored
Binary file not shown.
Reference in New Issue
Block a user