1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
/* camel-nntp-provider.c: nntp provider registration code */
6
* Chris Toshok <toshok@ximian.com>
8
* Copyright (C) 2000 Ximian, Inc. (www.ximian.com)
10
* This program is free software; you can redistribute it and/or
11
* modify it under the terms of version 2 of the GNU Lesser General Public
12
* License as published by the Free Software Foundation.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU Lesser General Public License for more details.
19
* You should have received a copy of the GNU Lesser General Public License
20
* along with this program; if not, write to the Free Software
21
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
31
#include <glib/gi18n-lib.h>
33
#include "camel-nntp-store.h"
34
#include "camel-provider.h"
35
#include "camel-session.h"
37
static void add_hash (guint *hash, char *s);
38
static guint nntp_url_hash (gconstpointer key);
39
static gint check_equal (char *s1, char *s2);
40
static gint nntp_url_equal (gconstpointer a, gconstpointer b);
42
static CamelProviderConfEntry nntp_conf_entries[] = {
43
{ CAMEL_PROVIDER_CONF_SECTION_START, "folders", NULL,
45
{ CAMEL_PROVIDER_CONF_CHECKBOX, "show_short_notation", NULL,
46
N_("Show folders in short notation (e.g. c.o.linux rather than comp.os.linux)"), "1" },
47
{ CAMEL_PROVIDER_CONF_CHECKBOX, "folder_hierarchy_relative", NULL,
48
N_("In the subscription dialog, show relative folder names"), "1" },
49
{ CAMEL_PROVIDER_CONF_SECTION_END },
50
{ CAMEL_PROVIDER_CONF_END }
53
static CamelProvider news_provider = {
57
N_("This is a provider for reading from and posting to "
58
"USENET newsgroups."),
62
CAMEL_PROVIDER_IS_REMOTE | CAMEL_PROVIDER_IS_SOURCE |
63
CAMEL_PROVIDER_IS_STORAGE | CAMEL_PROVIDER_SUPPORTS_SSL,
65
CAMEL_URL_NEED_HOST | CAMEL_URL_ALLOW_USER |
66
CAMEL_URL_ALLOW_PASSWORD | CAMEL_URL_ALLOW_AUTH,
73
CamelServiceAuthType camel_nntp_password_authtype = {
76
N_("This option will authenticate with the NNTP server using a "
77
"plaintext password."),
84
camel_provider_module_init(void)
86
news_provider.object_types[CAMEL_PROVIDER_STORE] = camel_nntp_store_get_type();
88
news_provider.url_hash = nntp_url_hash;
89
news_provider.url_equal = nntp_url_equal;
90
news_provider.authtypes = g_list_append (NULL, &camel_nntp_password_authtype);
91
news_provider.translation_domain = GETTEXT_PACKAGE;
93
camel_provider_register(&news_provider);
97
add_hash (guint *hash, char *s)
100
*hash ^= g_str_hash(s);
104
nntp_url_hash (gconstpointer key)
106
const CamelURL *u = (CamelURL *)key;
109
add_hash (&hash, u->user);
110
add_hash (&hash, u->host);
117
check_equal (char *s1, char *s2)
129
return strcmp (s1, s2) == 0;
133
nntp_url_equal (gconstpointer a, gconstpointer b)
135
const CamelURL *u1 = a, *u2 = b;
137
return check_equal(u1->protocol, u2->protocol)
138
&& check_equal (u1->user, u2->user)
139
&& check_equal (u1->host, u2->host)
140
&& u1->port == u2->port;