Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Ángel
evolution
Commits
ec170e47
Commit
ec170e47
authored
Oct 18, 2010
by
Matthew Barnes
Browse files
Move more account utilities to e-account-utils.c.
parent
e555c2bf
Changes
40
Hide whitespace changes
Inline
Side-by-side
capplet/settings/mail-account-view.c
View file @
ec170e47
...
...
@@ -32,7 +32,6 @@
#include
<libedataserver/e-account-list.h>
#include
"mail-view.h"
#include
"e-util/e-config.h"
#include
"mail/mail-config.h"
#include
"mail/e-mail-session.h"
#include
"mail-guess-servers.h"
...
...
capplet/settings/mail-settings-view.c
View file @
ec170e47
...
...
@@ -28,7 +28,6 @@
#include
"mail-settings-view.h"
#include
<libedataserver/e-account-list.h>
#include
"mail-view.h"
#include
"mail/mail-config.h"
#include
<e-util/e-account-utils.h>
struct
_MailSettingsViewPrivate
{
...
...
configure.ac
View file @
ec170e47
...
...
@@ -1284,7 +1284,7 @@ AC_SUBST(CERT_UI_LIBS)
dnl ************
dnl E_UTIL Flags
dnl ************
EVO_SET_COMPILE_FLAGS(E_UTIL, $LIBEDATASERVERUI camel-1.2 $mozilla_nspr, $MANUAL_NSPR_CFLAGS $MANUAL_NSPR_LIBS)
EVO_SET_COMPILE_FLAGS(E_UTIL, $LIBEDATASERVERUI camel-
provider-
1.2 $mozilla_nspr, $MANUAL_NSPR_CFLAGS $MANUAL_NSPR_LIBS)
AC_SUBST(E_UTIL_CFLAGS)
AC_SUBST(E_UTIL_LIBS)
...
...
doc/reference/shell/eshell-sections.txt
View file @
ec170e47
...
...
@@ -435,6 +435,10 @@ e_get_default_account
e_set_default_account
e_get_account_by_name
e_get_account_by_uid
e_get_account_by_source_url
e_get_account_by_transport_url
e_get_any_enabled_account
e_get_default_transport
</SECTION>
<SECTION>
...
...
doc/reference/shell/tmpl/e-account-utils.sgml
View file @
ec170e47
...
...
@@ -64,3 +64,39 @@ Mail Accounts
@Returns:
<!-- ##### FUNCTION e_get_account_by_source_url ##### -->
<para>
</para>
@source_url:
@Returns:
<!-- ##### FUNCTION e_get_account_by_transport_url ##### -->
<para>
</para>
@transport_url:
@Returns:
<!-- ##### FUNCTION e_get_any_enabled_account ##### -->
<para>
</para>
@void:
@Returns:
<!-- ##### FUNCTION e_get_default_transport ##### -->
<para>
</para>
@void:
@Returns:
e-util/e-account-utils.c
View file @
ec170e47
...
...
@@ -22,10 +22,31 @@
#include
"e-account-utils.h"
#include
<camel/camel.h>
#include
<gconf/gconf-client.h>
static
EAccountList
*
global_account_list
;
static
gboolean
account_has_source_url
(
EAccount
*
account
)
{
return
(
account
!=
NULL
)
&&
(
account
->
enabled
)
&&
(
account
->
source
!=
NULL
)
&&
(
account
->
source
->
url
!=
NULL
)
&&
(
account
->
source
->
url
[
0
]
!=
'\0'
);
}
static
gboolean
account_has_transport_url
(
EAccount
*
account
)
{
return
(
account
!=
NULL
)
&&
(
account
->
enabled
)
&&
(
account
->
transport
!=
NULL
)
&&
(
account
->
transport
->
url
!=
NULL
)
&&
(
account
->
transport
->
url
[
0
]
!=
'\0'
);
}
/**
* e_get_account_list:
*
...
...
@@ -138,6 +159,122 @@ e_get_account_by_uid (const gchar *uid)
return
(
EAccount
*
)
account
;
}
/**
* e_get_account_by_source_url:
* @source_url: a source URL
*
* Returns the #EAccount with the given source URL, or %NULL if no such
* account exists.
*
* Returns: an #EAccount having the given source URL, or %NULL
**/
EAccount
*
e_get_account_by_source_url
(
const
gchar
*
source_url
)
{
EAccountList
*
account_list
;
EAccount
*
account
=
NULL
;
EIterator
*
iterator
;
CamelProvider
*
provider
;
CamelURL
*
source_curl
;
g_return_val_if_fail
(
source_url
!=
NULL
,
NULL
);
source_curl
=
camel_url_new
(
source_url
,
NULL
);
g_return_val_if_fail
(
source_curl
!=
NULL
,
NULL
);
provider
=
camel_provider_get
(
source_url
,
NULL
);
g_return_val_if_fail
(
provider
!=
NULL
,
NULL
);
g_return_val_if_fail
(
provider
->
url_equal
!=
NULL
,
NULL
);
account_list
=
e_get_account_list
();
iterator
=
e_list_get_iterator
(
E_LIST
(
account_list
));
while
(
account
==
NULL
&&
e_iterator_is_valid
(
iterator
))
{
EAccount
*
candidate
;
CamelURL
*
curl
;
/* XXX EIterator misuses const. */
candidate
=
(
EAccount
*
)
e_iterator_get
(
iterator
);
e_iterator_next
(
iterator
);
if
(
!
account_has_source_url
(
candidate
))
continue
;
curl
=
camel_url_new
(
candidate
->
source
->
url
,
NULL
);
if
(
curl
==
NULL
)
continue
;
if
(
provider
->
url_equal
(
curl
,
source_curl
))
account
=
candidate
;
camel_url_free
(
curl
);
}
g_object_unref
(
iterator
);
camel_url_free
(
source_curl
);
return
account
;
}
/**
* e_get_account_by_transport_url:
* @transport_url: a transport URL
*
* Returns the #EAccount with the given transport URL, or %NULL if no
* such account exists.
*
* Returns: an #EAccount having the given transport URL, or %NULL
**/
EAccount
*
e_get_account_by_transport_url
(
const
gchar
*
transport_url
)
{
EAccountList
*
account_list
;
EAccount
*
account
=
NULL
;
EIterator
*
iterator
;
CamelProvider
*
provider
;
CamelURL
*
transport_curl
;
g_return_val_if_fail
(
transport_url
!=
NULL
,
NULL
);
transport_curl
=
camel_url_new
(
transport_url
,
NULL
);
g_return_val_if_fail
(
transport_curl
!=
NULL
,
NULL
);
provider
=
camel_provider_get
(
transport_url
,
NULL
);
g_return_val_if_fail
(
provider
!=
NULL
,
NULL
);
g_return_val_if_fail
(
provider
->
url_equal
!=
NULL
,
NULL
);
account_list
=
e_get_account_list
();
iterator
=
e_list_get_iterator
(
E_LIST
(
account_list
));
while
(
account
==
NULL
&&
e_iterator_is_valid
(
iterator
))
{
EAccount
*
candidate
;
CamelURL
*
curl
;
/* XXX EIterator misuses const. */
candidate
=
(
EAccount
*
)
e_iterator_get
(
iterator
);
e_iterator_next
(
iterator
);
if
(
!
account_has_transport_url
(
candidate
))
continue
;
curl
=
camel_url_new
(
candidate
->
transport
->
url
,
NULL
);
if
(
curl
==
NULL
)
continue
;
if
(
provider
->
url_equal
(
curl
,
transport_curl
))
account
=
candidate
;
camel_url_free
(
curl
);
}
g_object_unref
(
iterator
);
camel_url_free
(
transport_curl
);
return
account
;
}
/**
* e_get_any_enabled_account:
*
...
...
@@ -179,3 +316,42 @@ e_get_any_enabled_account (void)
return
account
;
}
/**
* e_get_default_transport:
*
* Returns transport information for the default account if it's enabled and
* has transport information, or else from the first enabled mail account in
* the global #EAccountList that has transport information, or finally %NULL
* if no transport information could be found.
*
* Returns: an #EAccountService with transport info, or %NULL
**/
EAccountService
*
e_get_default_transport
(
void
)
{
EAccountList
*
account_list
;
EAccount
*
account
;
EIterator
*
iterator
;
account
=
e_get_default_account
();
if
(
account_has_transport_url
(
account
))
return
account
->
transport
;
account_list
=
e_get_account_list
();
iterator
=
e_list_get_iterator
(
E_LIST
(
account_list
));
while
(
e_iterator_is_valid
(
iterator
))
{
/* XXX EIterator misuses const. */
account
=
(
EAccount
*
)
e_iterator_get
(
iterator
);
if
(
account_has_transport_url
(
account
))
{
g_object_unref
(
iterator
);
return
account
->
transport
;
}
e_iterator_next
(
iterator
);
}
g_object_unref
(
iterator
);
return
NULL
;
}
e-util/e-account-utils.h
View file @
ec170e47
...
...
@@ -18,7 +18,6 @@
#ifndef E_ACCOUNT_UTILS_H
#define E_ACCOUNT_UTILS_H
#include
<glib.h>
#include
<libedataserver/e-account.h>
#include
<libedataserver/e-account-list.h>
...
...
@@ -29,7 +28,11 @@ EAccount * e_get_default_account (void);
void
e_set_default_account
(
EAccount
*
account
);
EAccount
*
e_get_account_by_name
(
const
gchar
*
name
);
EAccount
*
e_get_account_by_uid
(
const
gchar
*
uid
);
EAccount
*
e_get_account_by_source_url
(
const
gchar
*
source_url
);
EAccount
*
e_get_account_by_transport_url
(
const
gchar
*
transport_url
);
EAccount
*
e_get_any_enabled_account
(
void
);
EAccountService
*
e_get_default_transport
(
void
);
G_END_DECLS
...
...
mail/e-mail-migrate.c
View file @
ec170e47
...
...
@@ -61,7 +61,6 @@
#include
"e-mail-store.h"
#include
"e-mail-backend.h"
#include
"mail-config.h"
#include
"em-utils.h"
#define d(x) x
...
...
mail/e-mail-reader-utils.c
View file @
ec170e47
...
...
@@ -38,7 +38,6 @@
#include
"mail/em-format-html-print.h"
#include
"mail/em-utils.h"
#include
"mail/mail-autofilter.h"
#include
"mail/mail-config.h"
#include
"mail/mail-ops.h"
#include
"mail/mail-tools.h"
#include
"mail/mail-vfolder.h"
...
...
mail/e-mail-reader.c
View file @
ec170e47
...
...
@@ -47,7 +47,6 @@
#include
"mail/em-folder-tree.h"
#include
"mail/em-utils.h"
#include
"mail/mail-autofilter.h"
#include
"mail/mail-config.h"
#include
"mail/mail-ops.h"
#include
"mail/mail-mt.h"
#include
"mail/mail-vfolder.h"
...
...
mail/e-mail-session.c
View file @
ec170e47
...
...
@@ -47,6 +47,7 @@
#include
<libedataserver/e-flag.h>
#include
"e-util/e-util.h"
#include
"e-util/e-account-utils.h"
#include
"e-util/e-alert-dialog.h"
#include
"e-util/e-util-private.h"
...
...
@@ -602,7 +603,7 @@ mail_session_get_password (CamelSession *session,
if
(
!
strcmp
(
item
,
"popb4smtp_uri"
))
{
/* not 100% mt safe, but should be ok */
if
(
url
&&
(
account
=
mail_config
_get_account_by_transport_url
(
url
)))
&&
(
account
=
e
_get_account_by_transport_url
(
url
)))
ret
=
g_strdup
(
account
->
source
->
url
);
else
ret
=
g_strdup
(
url
);
...
...
@@ -618,9 +619,9 @@ mail_session_get_password (CamelSession *session,
gboolean
remember
;
if
(
url
)
{
if
((
account
=
mail_config
_get_account_by_source_url
(
url
)))
if
((
account
=
e
_get_account_by_source_url
(
url
)))
config_service
=
account
->
source
;
else
if
((
account
=
mail_config
_get_account_by_transport_url
(
url
)))
else
if
((
account
=
e
_get_account_by_transport_url
(
url
)))
config_service
=
account
->
transport
;
}
...
...
mail/em-account-editor.c
View file @
ec170e47
...
...
@@ -64,7 +64,6 @@
#include
"em-account-editor.h"
#include
"mail-send-recv.h"
#include
"em-utils.h"
#include
"mail-config.h"
#include
"mail-ops.h"
#include
"mail-mt.h"
...
...
mail/em-composer-utils.c
View file @
ec170e47
...
...
@@ -35,7 +35,6 @@
#include
"mail-mt.h"
#include
"mail-ops.h"
#include
"mail-tools.h"
#include
"mail-config.h"
#include
"mail-send-recv.h"
#include
"e-util/e-account-utils.h"
...
...
@@ -816,7 +815,7 @@ create_new_composer (EShell *shell,
if
(
from_uri
!=
NULL
)
{
GList
*
list
;
account
=
mail_config
_get_account_by_source_url
(
from_uri
);
account
=
e
_get_account_by_source_url
(
from_uri
);
list
=
g_list_prepend
(
NULL
,
(
gpointer
)
from_uri
);
e_composer_header_table_set_post_to_list
(
table
,
list
);
...
...
@@ -881,7 +880,7 @@ em_utils_compose_new_message_with_mailto (EShell *shell,
table
=
e_msg_composer_get_header_table
(
composer
);
if
(
from_uri
&&
(
account
=
mail_config
_get_account_by_source_url
(
from_uri
)))
&&
(
account
=
e
_get_account_by_source_url
(
from_uri
)))
e_composer_header_table_set_account_name
(
table
,
account
->
name
);
composer_set_no_change
(
composer
);
...
...
mail/em-folder-properties.c
View file @
ec170e47
...
...
@@ -39,7 +39,6 @@
#include
"mail-ops.h"
#include
"mail-mt.h"
#include
"mail-vfolder.h"
#include
"mail-config.h"
struct
_prop_data
{
gpointer
object
;
...
...
mail/em-folder-selection-button.c
View file @
ec170e47
...
...
@@ -27,8 +27,8 @@
#include
<string.h>
#include
<glib/gi18n.h>
#include
<e-util/e-util.h>
#include
<e-util/e-account-utils.h>
#include
"mail-config.h"
#include
"em-folder-tree.h"
#include
"em-folder-selector.h"
#include
"em-utils.h"
...
...
@@ -100,7 +100,7 @@ folder_selection_button_set_contents (EMFolderSelectionButton *button)
return
;
}
account
=
mail_config
_get_account_by_source_url
(
uri
);
account
=
e
_get_account_by_source_url
(
uri
);
if
(
account
!=
NULL
)
{
gchar
*
tmp
=
folder_name
;
...
...
mail/em-folder-tree-model.c
View file @
ec170e47
...
...
@@ -35,7 +35,6 @@
#include
<glib/gi18n.h>
#include
"mail-config.h"
#include
"mail-tools.h"
#include
"mail-mt.h"
#include
"mail-ops.h"
...
...
@@ -1073,7 +1072,7 @@ em_folder_tree_model_add_store (EMFolderTreeModel *model,
uri
=
camel_url_to_string
(
((
CamelService
*
)
store
)
->
url
,
CAMEL_URL_HIDE_ALL
);
account
=
mail_config
_get_account_by_source_url
(
uri
);
account
=
e
_get_account_by_source_url
(
uri
);
/* Add the store to the tree. */
gtk_tree_store_append
(
tree_store
,
&
iter
,
NULL
);
...
...
mail/em-folder-tree.c
View file @
ec170e47
...
...
@@ -52,7 +52,6 @@
#include
"mail-mt.h"
#include
"mail-ops.h"
#include
"mail-tools.h"
#include
"mail-config.h"
#include
"mail-send-recv.h"
#include
"mail-vfolder.h"
...
...
@@ -2548,7 +2547,7 @@ em_folder_tree_set_selected_list (EMFolderTree *folder_tree,
/* This makes sure all our parents up to the root are
* expanded. FIXME: Why does the expanded state store
* this made up path rather than the euri? */
if
((
account
=
mail_config
_get_account_by_source_url
(
u
->
uri
)))
if
((
account
=
e
_get_account_by_source_url
(
u
->
uri
)))
expand_key
=
g_strdup_printf
(
"%s/%s"
,
account
->
uid
,
path
);
else
if
(
CAMEL_IS_VEE_STORE
(
u
->
store
))
expand_key
=
g_strdup_printf
(
"vfolder/%s"
,
path
);
...
...
mail/em-folder-utils.c
View file @
ec170e47
...
...
@@ -48,7 +48,6 @@
#include
"mail-mt.h"
#include
"mail-ops.h"
#include
"mail-tools.h"
#include
"mail-config.h"
#include
"mail-vfolder.h"
#include
"mail-folder-cache.h"
...
...
mail/em-format-html-display.c
View file @
ec170e47
...
...
@@ -55,8 +55,6 @@
#include
"e-cert-db.h"
#endif
#include
"mail-config.h"
#include
"e-mail-display.h"
#include
"e-mail-attachment-bar.h"
#include
"em-format-html-display.h"
...
...
mail/em-utils.c
View file @
ec170e47
...
...
@@ -53,7 +53,6 @@
#include
"mail-mt.h"
#include
"mail-ops.h"
#include
"mail-tools.h"
#include
"mail-config.h"
#include
"e-mail-tag-editor.h"
#include
<libedataserver/e-data-server-util.h>
...
...
@@ -1398,7 +1397,7 @@ gchar *em_uri_from_camel (const gchar *curi)
if
(
strcmp
(
curl
->
protocol
,
"vfolder"
)
==
0
)
uid
=
"vfolder@local"
;
else
if
((
account
=
mail_config
_get_account_by_source_url
(
curi
))
==
NULL
)
else
if
((
account
=
e
_get_account_by_source_url
(
curi
))
==
NULL
)
uid
=
"local@local"
;
else
uid
=
account
->
uid
;
...
...
@@ -2081,7 +2080,7 @@ guess_account_from_folder (CamelFolder *folder)
service
=
CAMEL_SERVICE
(
parent_store
);
source_url
=
camel_url_to_string
(
service
->
url
,
CAMEL_URL_HIDE_ALL
);
account
=
mail_config
_get_account_by_source_url
(
source_url
);
account
=
e
_get_account_by_source_url
(
source_url
);
g_free
(
source_url
);
return
account
;
...
...
@@ -2096,7 +2095,7 @@ guess_account_from_message (CamelMimeMessage *message)
if
(
source_url
==
NULL
)
return
NULL
;
return
mail_config
_get_account_by_source_url
(
source_url
);
return
e
_get_account_by_source_url
(
source_url
);
}
GHashTable
*
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment