Exemple #1
0
MsnNotification *
msn_notification_new(MsnSession *session)
{
    MsnNotification *notification;

    g_return_val_if_fail(session != NULL, NULL);

    notification = g_new0(MsnNotification, 1);

    notification->session = session;

    {
        PecanNode *conn;
        notification->conn = pecan_cmd_server_new ("notification server", PECAN_NODE_NS);
        conn = PECAN_NODE (notification->conn);

        {
            MsnCmdProc *cmdproc;
            cmdproc = notification->conn->cmdproc;
            cmdproc->session = session;
            cmdproc->cbs_table = cbs_table;
            cmdproc->conn = conn;
            cmdproc->error_handler = error_handler;
            cmdproc->data = notification;

            notification->cmdproc = cmdproc;
        }

        conn->session = session;

        if (session->http_method)
        {
            if (session->http_conn)
            {
                /* A single http connection shared by all nodes */
                pecan_node_link (conn, session->http_conn);
            }
            else
            {
                /* Each node has it's own http connection. */
                PecanNode *foo;

                foo = PECAN_NODE (pecan_http_server_new ("foo server"));
                foo->session = session;
                pecan_node_link (conn, foo);
                g_object_unref (foo);
            }
        }

        notification->open_handler = g_signal_connect (conn, "open", G_CALLBACK (open_cb), notification);
        notification->close_handler = g_signal_connect (conn, "close", G_CALLBACK (close_cb), notification);
        notification->error_handler = g_signal_connect (conn, "error", G_CALLBACK (close_cb), notification);
    }

    return notification;
}
Exemple #2
0
static void
close_cb (PecanNode *conn,
          MsnNotification *notification)
{
    char *tmp;

    {
        const char *reason = NULL;

        if (conn->error)
        {
            reason = conn->error->message;

            pecan_error ("connection error: (NS):reason=[%s]", reason);
            tmp = pecan_strdup_printf (_("Error on notification server:\n%s"), reason);

            g_clear_error (&conn->error);
        }
        else
        {
            pecan_error ("connection error: (NS)");
            tmp = pecan_strdup_printf (_("Error on notification server:\nUnknown"));
        }
    }

    pecan_node_close (PECAN_NODE (notification->conn));
    notification->closed = TRUE;
    msn_session_set_error (notification->session, MSN_ERROR_SERVCONN, tmp);

    g_free (tmp);
}
Exemple #3
0
void
pecan_session_connect (PecanSession *session,
                       const gchar *host,
                       gint port)
{
    pecan_node_connect (PECAN_NODE (session->priv->ns), host, port);
}
Exemple #4
0
gboolean
msn_notification_connect(MsnNotification *notification, const char *host, int port)
{
    g_return_val_if_fail(notification != NULL, FALSE);

    pecan_node_connect (PECAN_NODE (notification->conn), host, port);

    return TRUE;
}
Exemple #5
0
void
msn_notification_close(MsnNotification *notification)
{
    g_return_if_fail(notification != NULL);

    if (!notification->closed)
    {
        msn_cmdproc_send_quick (notification->cmdproc, "OUT", NULL, NULL);
        pecan_node_close (PECAN_NODE (notification->conn));
    }
}
PecanCmdServer *
pecan_cmd_server_new (const gchar *name,
                      PecanNodeType type)
{
    PecanCmdServer *conn;

    pecan_log ("begin");

    conn = CMD_PECAN_NODE (g_type_create_instance (CMD_PECAN_NODE_TYPE));

    {
        PecanNode *tmp = PECAN_NODE (conn);
        tmp->name = g_strdup (name);
        tmp->type = type;
    }

    pecan_log ("end");

    return conn;
}
Exemple #7
0
void
pecan_session_disconnect (PecanSession *session)
{
    pecan_node_close (PECAN_NODE (session->priv->ns));
}