~ubuntu-branches/ubuntu/natty/empathy/natty

« back to all changes in this revision

Viewing changes to .pc/enable_pidgin_imported_contacts.patch/src/empathy-import-utils.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell, Omer Akram
  • Date: 2011-01-06 14:32:31 UTC
  • Revision ID: james.westby@ubuntu.com-20110106143231-ol0gyfqi7h1ch8kv
Tags: 2.32.2-0ubuntu3
* debian/patches/00git_folks_api.patch:
  - Update to latest folks API

[ Omer Akram ]
* debian/patches/enable_pidgin_imported_contacts.patch:
  - Enable pidgin imported accounts by default. (LP: #622215)
* debian/patches/reword_subscription_dailog_to_be_less_technical.patch:
  - Reword subscription request dialog to be less technical. (LP: #670197)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2009 Collabora Ltd.
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Lesser General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2.1 of the License, or (at your option) any later version.
 
8
 *
 
9
 * This library is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * Lesser General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Lesser General Public
 
15
 * License along with this library; if not, write to the Free Software
 
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
17
 *
 
18
 * Authors: Jonny Lamb <jonny.lamb@collabora.co.uk>
 
19
 *          Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
 
20
 */
 
21
 
 
22
#include <telepathy-glib/util.h>
 
23
 
 
24
#include <libempathy/empathy-connection-managers.h>
 
25
#include <libempathy/empathy-utils.h>
 
26
 
 
27
#include "empathy-import-utils.h"
 
28
#include "empathy-import-pidgin.h"
 
29
 
 
30
EmpathyImportAccountData *
 
31
empathy_import_account_data_new (const gchar *source)
 
32
{
 
33
  EmpathyImportAccountData *data;
 
34
 
 
35
  g_return_val_if_fail (!EMP_STR_EMPTY (source), NULL);
 
36
 
 
37
  data = g_slice_new0 (EmpathyImportAccountData);
 
38
  data->settings = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
 
39
    (GDestroyNotify) tp_g_value_slice_free);
 
40
  data->source = g_strdup (source);
 
41
  data->protocol = NULL;
 
42
  data->connection_manager = NULL;
 
43
 
 
44
  return data;
 
45
}
 
46
 
 
47
void
 
48
empathy_import_account_data_free (EmpathyImportAccountData *data)
 
49
{
 
50
  if (data == NULL)
 
51
    return;
 
52
  if (data->protocol != NULL)
 
53
    g_free (data->protocol);
 
54
  if (data->connection_manager != NULL)
 
55
    g_free (data->connection_manager);
 
56
  if (data->settings != NULL)
 
57
    g_hash_table_destroy (data->settings);
 
58
  if (data->source != NULL)
 
59
    g_free (data->source);
 
60
 
 
61
  g_slice_free (EmpathyImportAccountData, data);
 
62
}
 
63
 
 
64
gboolean
 
65
empathy_import_accounts_to_import (void)
 
66
{
 
67
  return empathy_import_pidgin_accounts_to_import ();
 
68
}
 
69
 
 
70
GList *
 
71
empathy_import_accounts_load (EmpathyImportApplication id)
 
72
{
 
73
  if (id == EMPATHY_IMPORT_APPLICATION_PIDGIN)
 
74
    return empathy_import_pidgin_load ();
 
75
 
 
76
  return empathy_import_pidgin_load ();
 
77
}
 
78
 
 
79
gboolean
 
80
empathy_import_protocol_is_supported (const gchar *protocol,
 
81
    TpConnectionManager **cm)
 
82
{
 
83
  EmpathyConnectionManagers *manager;
 
84
  GList *cms;
 
85
  GList *l;
 
86
  gboolean proto_is_supported = FALSE;
 
87
 
 
88
  manager = empathy_connection_managers_dup_singleton ();
 
89
  cms = empathy_connection_managers_get_cms (manager);
 
90
 
 
91
  for (l = cms; l; l = l->next)
 
92
    {
 
93
 
 
94
      TpConnectionManager *tp_cm = l->data;
 
95
      if (tp_connection_manager_has_protocol (tp_cm,
 
96
          (const gchar*) protocol))
 
97
        {
 
98
          if (!proto_is_supported)
 
99
            {
 
100
              *cm = tp_cm;
 
101
              proto_is_supported = TRUE;
 
102
 
 
103
              continue;
 
104
            }
 
105
 
 
106
          /* we have more than one CM for this protocol,
 
107
           * select the one which is not haze.
 
108
           */
 
109
          if (!tp_strdiff ((*cm)->name, "haze"))
 
110
            {
 
111
              *cm = tp_cm;
 
112
              break;
 
113
            }
 
114
        }
 
115
    }
 
116
 
 
117
  g_object_unref (manager);
 
118
 
 
119
  return proto_is_supported;
 
120
}