static PyObject *pysilc_client_run_one(PyObject *self)
{
    PySilcClient *pyclient = (PySilcClient *)self;
    if (!pyclient || !pyclient->silcobj) {
           PyErr_SetString(PyExc_RuntimeError, "SILC Client Not Initialised");
           return NULL;
    }
    silc_client_run_one(pyclient->silcobj);
    Py_RETURN_NONE;
}
Beispiel #2
0
int weechat_plugin_init(struct t_weechat_plugin *plugin, int argc, char *argv[]) {
    weechat_plugin = plugin;
    SilcClientParams params;

    if (silc_plugin_config_init() < 0) {
        weechat_log_printf("could not initialize SILC plugin config");
        return WEECHAT_RC_ERROR;
    }

    if (silc_plugin_config_read() < 0) {
        weechat_log_printf("could not read SILC plugin config file");
        return WEECHAT_RC_ERROR;
    }

    memset(&params, 0, sizeof(params));
    params.threads = TRUE;

    silc_plugin = silc_calloc(1, sizeof(*silc_plugin));
    if (!silc_plugin) {
        weechat_log_printf("could not allocate plugin context");
        return WEECHAT_RC_ERROR;
    }
    weechat_log_printf("SILC plugin context allocated");

    silc_plugin->client = silc_client_alloc(&ops, &params, silc_plugin, NULL);
    if (!silc_plugin->client) {
        weechat_log_printf("could not allocate SILC client");
        return WEECHAT_RC_ERROR;
    }
    weechat_log_printf("SILC client allocated");

    if (!silc_client_init(silc_plugin->client, weechat_config_string(option_default_username),
                silc_net_localhost(), weechat_config_string(option_default_realname), silc_running, silc_plugin)) {
        weechat_log_printf("could not initialize SILC client");
        return WEECHAT_RC_ERROR;
    }
    // tick the client once to complete the initialization
    silc_client_run_one(silc_plugin->client);
    weechat_log_printf("SILC client initialized");

    silc_plugin_get_keypair("weechat", "", 1, &silc_plugin->public_key, &silc_plugin->private_key);

    server_list = malloc(sizeof(struct SilcPluginServer));
    memset(server_list, 0, sizeof(struct SilcPluginServer));

    weechat_hook_command("silc", "This is the SILC plugin", "", "", NULL, &command_silc, NULL);
    weechat_hook_timer(50, 0, 0, &timer_silc, NULL);

    silc_bar_init();

    return WEECHAT_RC_OK;
}
Beispiel #3
0
// this is the simulation of a main loop that makes the silc client do its work
int timer_silc(void *data, int remaining_calls) {
    silc_client_run_one(silc_plugin->client);
    return WEECHAT_RC_OK;
}