diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | embed/ephy-permission-manager.c | 21 | ||||
-rw-r--r-- | embed/ephy-permission-manager.h | 19 | ||||
-rw-r--r-- | embed/mozilla/EphySingle.cpp | 10 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed-single.cpp | 26 |
5 files changed, 57 insertions, 29 deletions
@@ -1,3 +1,13 @@ +2003-12-12 Christian Persch <chpe@cvs.gnome.org> + + * embed/ephy-permission-manager.c: (ephy_permission_info_new), + (ephy_permission_info_copy), (ephy_permission_manager_add): + * embed/ephy-permission-manager.h: + * embed/mozilla/EphySingle.cpp: + * embed/mozilla/mozilla-embed-single.cpp: + + Fix permission return types. + 2003-12-10 Christian Persch <chpe@cvs.gnome.org> * data/glade/print.glade: diff --git a/embed/ephy-permission-manager.c b/embed/ephy-permission-manager.c index b4b60ab78..22add0d0b 100644 --- a/embed/ephy-permission-manager.c +++ b/embed/ephy-permission-manager.c @@ -55,13 +55,13 @@ ephy_permission_info_get_type (void) EphyPermissionInfo * ephy_permission_info_new (const char *host, EphyPermissionType type, - gboolean allowed) + EphyPermission permission) { EphyPermissionInfo *info = g_new0 (EphyPermissionInfo, 1); info->host = g_strdup (host); info->type = type; - info->allowed = allowed; + info->permission = permission; return info; } @@ -79,7 +79,7 @@ ephy_permission_info_copy (const EphyPermissionInfo *info) copy->host = g_strdup (info->host); copy->type = info->type; - copy->allowed = info->allowed; + copy->permission = info->permission; return copy; } @@ -213,7 +213,7 @@ ephy_permission_manager_base_init (gpointer g_class) * @manager: the #EphyPermissionManager * @host: a host name * @type: a #EphyPermissionType - * @allow: the permission itself + * @permission: either #EPHY_PERMISSION_ALLOWED or #EPHY_PERMISSION_DENIED * * Adds the permission @allow of type @type for host @host to the permissions * database. @@ -222,10 +222,10 @@ void ephy_permission_manager_add (EphyPermissionManager *manager, const char *host, EphyPermissionType type, - gboolean allow) + EphyPermission permission) { EphyPermissionManagerIFace *iface = EPHY_PERMISSION_MANAGER_GET_IFACE (manager); - iface->add (manager, host, type, allow); + iface->add (manager, host, type, permission); } /** @@ -265,11 +265,12 @@ ephy_permission_manager_clear (EphyPermissionManager *manager) * @host: a host name * @type: a #EphyPermissionType * - * Tests whether the host @host is allowed to do the action specified by @type. - * - * Return value: TRUE if allowed + * Gets the permission of @host for type @type. If there is no entry + * for this type for @host, it will return #EPHY_PERMISSION_DEFAULT. + * + * Return value: the permission of type #EphyPermission **/ -gboolean +EphyPermission ephy_permission_manager_test (EphyPermissionManager *manager, const char *host, EphyPermissionType type) diff --git a/embed/ephy-permission-manager.h b/embed/ephy-permission-manager.h index 644797925..d049f3fd4 100644 --- a/embed/ephy-permission-manager.h +++ b/embed/ephy-permission-manager.h @@ -46,11 +46,18 @@ typedef enum EPT_POPUP } EphyPermissionType; +typedef enum +{ + EPHY_PERMISSION_ALLOWED, + EPHY_PERMISSION_DENIED, + EPHY_PERMISSION_DEFAULT +} EphyPermission; + typedef struct { char *host; EphyPermissionType type; - gboolean allowed; + EphyPermission permission; } EphyPermissionInfo; struct EphyPermissionManagerIFace @@ -70,12 +77,12 @@ struct EphyPermissionManagerIFace void (* add) (EphyPermissionManager *manager, const char *host, EphyPermissionType type, - gboolean allow); + EphyPermission permission); void (* remove) (EphyPermissionManager *manager, const char *host, EphyPermissionType type); void (* clear) (EphyPermissionManager *manager); - gboolean (* test) (EphyPermissionManager *manager, + EphyPermission (* test) (EphyPermissionManager *manager, const char *host, EphyPermissionType type); GList * (* list) (EphyPermissionManager *manager, @@ -88,7 +95,7 @@ GType ephy_permission_info_get_type (void); EphyPermissionInfo *ephy_permission_info_new (const char *host, EphyPermissionType type, - gboolean allowed); + EphyPermission permission); EphyPermissionInfo *ephy_permission_info_copy (const EphyPermissionInfo *info); @@ -101,7 +108,7 @@ GType ephy_permission_manager_get_type (void); void ephy_permission_manager_add (EphyPermissionManager *manager, const char *host, EphyPermissionType type, - gboolean allow); + EphyPermission permission); void ephy_permission_manager_remove (EphyPermissionManager *manager, const char *host, @@ -109,7 +116,7 @@ void ephy_permission_manager_remove (EphyPermissionManager *manager, void ephy_permission_manager_clear (EphyPermissionManager *manager); -gboolean ephy_permission_manager_test (EphyPermissionManager *manager, +EphyPermission ephy_permission_manager_test (EphyPermissionManager *manager, const char *host, EphyPermissionType type); diff --git a/embed/mozilla/EphySingle.cpp b/embed/mozilla/EphySingle.cpp index 1762b2e18..b9566a329 100644 --- a/embed/mozilla/EphySingle.cpp +++ b/embed/mozilla/EphySingle.cpp @@ -301,21 +301,23 @@ mozilla_permission_to_ephy_permission (nsIPermission *perm) PRUint32 cap; perm->GetCapability(&cap); - gboolean allowed; + EphyPermission permission; switch (cap) { case nsIPermissionManager::ALLOW_ACTION: - allowed = TRUE; + permission = EPHY_PERMISSION_ALLOWED; break; case nsIPermissionManager::DENY_ACTION: + permission = EPHY_PERMISSION_DENIED; + break; case nsIPermissionManager::UNKNOWN_ACTION: default : - allowed = FALSE; + permission = EPHY_PERMISSION_DEFAULT; break; } nsCString host; perm->GetHost(host); - return ephy_permission_info_new (host.get(), type, allowed); + return ephy_permission_info_new (host.get(), type, permission); } diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp index b6c0a22f2..f60c60bee 100644 --- a/embed/mozilla/mozilla-embed-single.cpp +++ b/embed/mozilla/mozilla-embed-single.cpp @@ -730,8 +730,11 @@ void impl_permission_manager_add (EphyPermissionManager *manager, const char *host, EphyPermissionType type, - gboolean allow) + EphyPermission permission) { + /* can only set allow or deny */ + g_return_if_fail (permission != EPHY_PERMISSION_DEFAULT); + nsresult result; nsCOMPtr<nsIPermissionManager> pm (do_GetService (NS_PERMISSIONMANAGER_CONTRACTID, &result)); @@ -741,6 +744,8 @@ impl_permission_manager_add (EphyPermissionManager *manager, result = NS_NewURI(getter_AddRefs(uri), host); if (NS_FAILED(result) || !uri) return; + gboolean allow = (permission == EPHY_PERMISSION_ALLOWED); + pm->Add (uri, #if MOZILLA_SNAPSHOT >= 10 permission_type_string [type], @@ -781,7 +786,7 @@ impl_permission_manager_clear (EphyPermissionManager *manager) } } -gboolean +EphyPermission impl_permission_manager_test (EphyPermissionManager *manager, const char *host, EphyPermissionType type) @@ -789,11 +794,11 @@ impl_permission_manager_test (EphyPermissionManager *manager, nsresult result; nsCOMPtr<nsIPermissionManager> pm (do_GetService (NS_PERMISSIONMANAGER_CONTRACTID, &result)); - if (NS_FAILED (result) || !pm) return FALSE; + if (NS_FAILED (result) || !pm) return EPHY_PERMISSION_DEFAULT; nsCOMPtr<nsIURI> uri; result = NS_NewURI(getter_AddRefs(uri), host); - if (NS_FAILED(result) || !uri) return FALSE; + if (NS_FAILED(result) || !uri) return EPHY_PERMISSION_DEFAULT; PRUint32 action; #if MOZILLA_SNAPSHOT >= 10 @@ -801,22 +806,25 @@ impl_permission_manager_test (EphyPermissionManager *manager, #else result = pm->TestPermission (uri, type, &action); #endif - if (NS_FAILED (result)) return FALSE; + if (NS_FAILED (result)) return EPHY_PERMISSION_DEFAULT; + + EphyPermission permission; - gboolean allow; switch (action) { case nsIPermissionManager::ALLOW_ACTION: - allow = TRUE; + permission = EPHY_PERMISSION_ALLOWED; break; case nsIPermissionManager::DENY_ACTION: + permission = EPHY_PERMISSION_DENIED; + break; case nsIPermissionManager::UNKNOWN_ACTION: default: - allow = FALSE; + permission = EPHY_PERMISSION_DEFAULT; break; } - return allow; + return permission; } GList * |