Dummy status, login and logout methods

This commit is contained in:
2018-05-02 01:31:18 +01:00
parent 6fcd10ed32
commit 2049e30dc5
3 changed files with 76 additions and 4 deletions

31
delta-connection.c Normal file
View File

@@ -0,0 +1,31 @@
#include <connection.h>
#include "delta-connection.h"
void delta_connection_new(PurpleConnection *pc)
{
DeltaConnectionData *conn;
g_assert(purple_connection_get_protocol_data(pc) == NULL);
conn = g_new0(DeltaConnectionData, 1);
conn->pc = pc;
purple_connection_set_protocol_data(pc, conn);
}
void delta_connection_free(PurpleConnection *pc)
{
DeltaConnectionData *conn = purple_connection_get_protocol_data(pc);
g_assert(conn != NULL);
purple_connection_set_protocol_data(pc, NULL);
// TODO: free resources as they are added to DeltaConnectionData
conn->pc = NULL;
g_free(conn);
}

16
delta-connection.h Normal file
View File

@@ -0,0 +1,16 @@
#ifndef DELTA_CONNECTION_H
#define DELTA_CONNECTION_H
#include <glib.h>
struct _PurpleConnection;
typedef struct _DeltaConnectionData {
struct _PurpleConnection *pc;
} DeltaConnectionData;
void delta_connection_new(struct _PurpleConnection *pc);
void delta_connection_free(struct _PurpleConnection *pc);
#endif

View File

@@ -6,12 +6,15 @@
// All from libpurple
#include <accountopt.h>
#include <connection.h>
#include <debug.h>
#include <notify.h>
#include <plugin.h>
#include <prpl.h>
#include <version.h>
#include "delta-connection.h"
#define UNUSED(x) (void)(x)
static void
@@ -20,16 +23,38 @@ debug(const char *str)
purple_debug_info(PLUGIN_ID, str);
}
static void
delta_login()
static GList *
delta_status_types(PurpleAccount *acct)
{
UNUSED(acct);
GList *types = NULL;
types = g_list_append(types, purple_status_type_new(PURPLE_STATUS_OFFLINE, "Offline", NULL, TRUE));
types = g_list_append(types, purple_status_type_new(PURPLE_STATUS_AVAILABLE, "Online", NULL, TRUE));
return types;
}
static void
delta_close()
delta_login(PurpleAccount *acct)
{
PurpleConnection *pc = purple_account_get_connection(acct);
delta_connection_new(pc);
purple_connection_set_state(pc, PURPLE_CONNECTING);
// TODO: attempt to connect!
pc->flags |= PURPLE_CONNECTION_HTML;
}
static void
delta_close(PurpleConnection *pc)
{
// TODO: actually disconnect!
purple_connection_set_state(pc, PURPLE_DISCONNECTED);
delta_connection_free(pc);
}
// Below the fold is libpurple plumbing. No, I don't understand it either
@@ -119,7 +144,7 @@ static PurplePluginProtocolInfo extra_info =
NULL, /* list_emblem */
NULL, /* status_text */
NULL, /* tooltip_text */
NULL, /* status_types */
delta_status_types, /* status_types */
NULL, /* blist_node_menu */
NULL, /* chat_info */
NULL, /* chat_info_defaults */