1 /* $Id: ggadu_repo.h,v 1.4 2004/12/26 22:23:16 shaster Exp $ */ 2 3 /* 4 * GNU Gadu 2 5 * 6 * Copyright (C) 2001-2005 GNU Gadu Team 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 */ 22 23 #ifndef GGadu_REPO_H 24 #define GGadu_REPO_H 1 25 26 #include <glib.h> 27 #include <limits.h> 28 29 #ifndef GG2_CORE_H 30 #include "ggadu_types.h" 31 #endif 32 33 typedef void (*watch_ptr) (gchar *, gpointer, gint); 34 typedef gpointer GGaduRepoKey; 35 36 typedef struct 37 { 38 gpointer key; 39 gpointer value; 40 gint type; 41 GSList *watches; 42 } GGaduRepoValue; 43 44 typedef struct 45 { 46 gchar *name; 47 GSList *values; 48 GSList *watches; 49 } GGaduRepo; 50 51 typedef struct 52 { 53 gint actions; 54 gint types; 55 watch_ptr callback; 56 } GGaduRepoWatch; 57 58 gboolean ggadu_repo_check_value(gchar * repo_name, gpointer key); 59 gpointer ggadu_repo_find_value(gchar * repo_name, gpointer key); 60 gboolean ggadu_repo_exists(gchar * repo_name); 61 62 enum 63 { 64 REPO_VALUE_DC = 0, /* don't change */ 65 REPO_VALUE_CONTACT = 1, 66 REPO_VALUE_SETTING = 2, 67 REPO_VALUE_PROTOCOL = 4, 68 REPO_VALUE_OTHER = 8, 69 70 REPO_VALUE_ANY = INT_MAX 71 }; 72 73 void ggadu_repo_disable_notification(); 74 void ggadu_repo_enable_notification(); 75 76 GGaduRepoKey ggadu_repo_key_from_string(gchar * key); 77 gboolean ggadu_repo_add(gchar * repo_name); 78 gboolean ggadu_repo_add_value(gchar * repo_name, gpointer key, gpointer value, gint type); 79 gboolean ggadu_repo_change_value(gchar * repo_name, gpointer key, gpointer value, gint type); 80 gboolean ggadu_repo_del_value(gchar * repo_name, gpointer key); 81 gboolean ggadu_repo_del(gchar * repo_name); 82 83 gpointer ggadu_repo_value_first(gchar * repo_name, gint type, gpointer * data); 84 gpointer ggadu_repo_value_next(gchar * repo_name, gint type, gpointer * data, gpointer index); 85 GSList* ggadu_repo_get_as_slist(gchar * repo_name, gint type); 86 87 enum 88 { 89 REPO_ACTION_NEW = 1, /* dodanie nowego repo */ 90 REPO_ACTION_DEL = 2, /* usuni�cie danego repo */ 91 REPO_ACTION_CHANGE = 4, /* zmiana w danym repo (warto�ci) */ 92 REPO_ACTION_VALUE_NEW = 8, /* nowa warto�� w repo */ 93 REPO_ACTION_VALUE_DEL = 16, /* usuni�cie warto�ci */ 94 REPO_ACTION_VALUE_CHANGE = 32 /* zmiana warto�ci */ 95 }; 96 97 extern const gint REPO_mask; 98 extern const gint REPO_value_mask; 99 100 /* Czym si� r�ni REPO_ACTION_VALUE_* od REPO_ACTION_CHANGE? 101 * Ano tym, �e REPO_ACTION_CHANGE stwierdza tylko, czy co� si� zmieni�o w repo. 102 * A to co� to dowolna warto��. 103 * 104 * REPO_ACTION_VALUE_* tyczy si� tylko jednej, podanej warto�ci. 105 * 106 * Je�li jeden callback obs�uguje np. REPO_ACTION_VALUE_NEW 107 * i REPO_ACTION_CHANGE, 108 * to gdy zostanie dodana nowa warto��, to callback zostanie poinformowany 109 * o REPO_ACTION_VALUE_NEW. 110 * 111 * Je�li jest usuwane repo, to niezale�nie od podanych masek, zawsze wysy�any 112 * jest REPO_ACTION_DEL. 113 * 114 * Informacje o usuni�ciu s� wysy�ane przed usuni�ciem danych z repo, natomiast 115 * inne informacje ju� po dodaniu/modyfikacji. 116 */ 117 118 /* GGaduRepo_watch_add(gchar *repo_name,gpointer key,gint actions,gpointer callback) 119 * 120 * repo_name - nazwa repo, w kt�rym jest nas�uch 121 * actions - maska, okre�laj�ca akcje, przy kt�rych wywo�ywany jest callback 122 * key - klucz, kt�ry ma by� sprawdzany (je�li w actions siedzi jedno 123 * z *_VALUE_*) 124 * callback - wska�nik do funkcji, przyjmuj�cej trzy argumenty: 125 * callback (gchar *repo_name, gpointer key, gint actions) 126 * actions zawiera informacje o akcji na danym repo lub key 127 * 128 * Kolejne wywo�ania GGaduRepo_watch_add z tymi samymi danymi (repo_name, key, 129 * callback) 130 * uaktualnia mask� akcji (dodaje brakuj�ce elementy). 131 * 132 * GGaduRepo_watch_del() usuwa podane akcje odnosz�ce si� do danego repo 133 * (repo_name), klucza 134 * (key) oraz callbacku (callback). Je�li actions jest r�wne actions podanym 135 * funkcji 136 * GGaduRepo_watch_add(), to watch jest ca�kowicie usuwany. 137 */ 138 gboolean ggadu_repo_watch_add(gchar * repo_name, gint actions, gint types, watch_ptr callback); 139 gboolean ggadu_repo_watch_del(gchar * repo_name, gint actions, gint types, watch_ptr callback); 140 141 gboolean ggadu_repo_watch_value_add(gchar * repo_name, gpointer key, gint actions, watch_ptr callback); 142 gboolean ggadu_repo_watch_value_del(gchar * repo_name, gpointer key, gint actions, watch_ptr callback); 143 144 gboolean ggadu_repo_watch_clear_callback(watch_ptr callback); 145 146 #endif 147