summaryrefslogtreecommitdiff
path: root/src/connection-manager/connection-manager.c
blob: 824ea2e3bfd0844737c6ed62740793cea68bb6ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* telepathy-gruschler - A Telepathy connection manager for social networks.
 * Copyright (C) 2009  Mathias Hasselmann
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
#include "config.h"
#include "connection-manager.h"
#include "facebook-connection.h"

G_DEFINE_TYPE (GruschlerConnectionManager,
               gruschler_connection_manager,
               TP_TYPE_BASE_CONNECTION_MANAGER);

static const TpCMParamSpec gruschler_facebook_connection_params[] = {
    { "email", "s", G_TYPE_STRING,
      TP_CONN_MGR_PARAM_FLAG_REQUIRED |
      TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT,
      GRUSCHLER_FACEBOOK_DEFAULT_EMAIL,
      G_STRUCT_OFFSET (GruschlerFacebookConnectionParams, email),
      NULL, NULL, NULL },

    { "password", "s", G_TYPE_STRING,
      TP_CONN_MGR_PARAM_FLAG_REQUIRED |
      TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT |
      TP_CONN_MGR_PARAM_FLAG_SECRET,
      GRUSCHLER_FACEBOOK_DEFAULT_PASSWORD,
      G_STRUCT_OFFSET (GruschlerFacebookConnectionParams, password),
      NULL, NULL, NULL },

    { NULL, }
};

static void
gruschler_connection_manager_init (GruschlerConnectionManager *self)
{
}

static TpBaseConnection *
gruschler_connection_manager_new_connection (TpBaseConnectionManager  *self,
                                             const char               *proto,
                                             TpIntSet                 *params_present,
                                             void                     *parsed_params,
                                             GError                  **error)
{
  if (!g_strcmp0 (proto, "facebook"))
    return gruschler_facebook_connection_new (self, parsed_params, error);

  g_set_error (error, TP_ERRORS,
               TP_ERROR_INVALID_ARGUMENT,
               "unknown protocol name %s", proto);

  return NULL;
}

static void
gruschler_connection_manager_class_init (GruschlerConnectionManagerClass *class)
{
  static const TpCMProtocolSpec protocol_params[] = {
      { "facebook",
        gruschler_facebook_connection_params,
        gruschler_facebook_connection_params_new,
        gruschler_facebook_connection_params_free, NULL
      },

      { NULL, }
  };

  TpBaseConnectionManagerClass *base_cm_class;

  base_cm_class                  = TP_BASE_CONNECTION_MANAGER_CLASS (class);
  base_cm_class->cm_dbus_name    = "gruschler";
  base_cm_class->protocol_params = protocol_params;
  base_cm_class->new_connection  = gruschler_connection_manager_new_connection;
}

TpBaseConnectionManager *
gruschler_connection_manager_new (void)
{
  return g_object_new (GRUSCHLER_TYPE_CONNECTION_MANAGER, NULL);
}