Use an ast_flags structure in aji_client and aji_buddy rather than an

integer. Modify calls to various ast_*_flag macros accordingly.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@103341 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Philippe Sultan
2008-02-12 14:08:58 +00:00
parent 16a14a4cd8
commit f98f90af49
2 changed files with 15 additions and 15 deletions

View File

@@ -126,7 +126,7 @@ struct aji_buddy {
char channel[160];
struct aji_resource *resources;
enum aji_btype btype;
unsigned int flags;
struct ast_flags flags;
};
struct aji_buddy_container {
@@ -167,7 +167,7 @@ struct aji_client {
int timeout;
int message_timeout;
int authorized;
unsigned int flags;
struct ast_flags flags;
int component; /* 0 client, 1 component */
struct aji_buddy_container buddies;
AST_LIST_HEAD(messages,aji_message) messages;

View File

@@ -2062,7 +2062,7 @@ static void aji_pruneregister(struct aji_client *client)
ASTOBJ_RDLOCK(iterator);
/* For an aji_buddy, both AUTOPRUNE and AUTOREGISTER will never
* be called at the same time */
if (ast_test_flag(iterator, AJI_AUTOPRUNE)) {
if (ast_test_flag(&iterator->flags, AJI_AUTOPRUNE)) {
res = ast_aji_send(client, iks_make_s10n(IKS_TYPE_UNSUBSCRIBE, iterator->name,
"GoodBye your status is no longer needed by Asterisk the Open Source PBX"
" so I am no longer subscribing to your presence.\n"));
@@ -2075,10 +2075,10 @@ static void aji_pruneregister(struct aji_client *client)
iks_insert_attrib(removeitem, "jid", iterator->name);
iks_insert_attrib(removeitem, "subscription", "remove");
res = ast_aji_send(client, removeiq);
} else if (ast_test_flag(iterator, AJI_AUTOREGISTER)) {
} else if (ast_test_flag(&iterator->flags, AJI_AUTOREGISTER)) {
res = ast_aji_send(client, iks_make_s10n(IKS_TYPE_SUBSCRIBE, iterator->name,
"Greetings I am the Asterisk Open Source PBX and I want to subscribe to your presence\n"));
ast_clear_flag(iterator, AJI_AUTOREGISTER);
ast_clear_flag(&iterator->flags, AJI_AUTOREGISTER);
}
ASTOBJ_UNLOCK(iterator);
});
@@ -2117,13 +2117,13 @@ static int aji_filter_roster(void *data, ikspak *pak)
if (!iks_strcmp(iks_name(x), "item")) {
if (!strcasecmp(iterator->name, iks_find_attrib(x, "jid"))) {
flag = 1;
ast_clear_flag(iterator, AJI_AUTOPRUNE | AJI_AUTOREGISTER);
ast_clear_flag(&iterator->flags, AJI_AUTOPRUNE | AJI_AUTOREGISTER);
}
}
x = iks_next(x);
}
if (!flag)
ast_copy_flags(iterator, client, AJI_AUTOREGISTER);
ast_copy_flags(&iterator->flags, &client->flags, AJI_AUTOREGISTER);
if (x)
iks_delete(x);
ASTOBJ_UNLOCK(iterator);
@@ -2149,12 +2149,12 @@ static int aji_filter_roster(void *data, ikspak *pak)
ASTOBJ_INIT(buddy);
ASTOBJ_WRLOCK(buddy);
ast_copy_string(buddy->name, iks_find_attrib(x, "jid"), sizeof(buddy->name));
ast_clear_flag(buddy, AST_FLAGS_ALL);
if(ast_test_flag(client, AJI_AUTOPRUNE)) {
ast_set_flag(buddy, AJI_AUTOPRUNE);
buddy->objflags |= ASTOBJ_FLAG_MARKED;
ast_clear_flag(&buddy->flags, AST_FLAGS_ALL);
if(ast_test_flag(&client->flags, AJI_AUTOPRUNE)) {
ast_set_flag(&buddy->flags, AJI_AUTOPRUNE);
ASTOBJ_MARK(buddy);
} else
ast_set_flag(buddy, AJI_AUTOREGISTER);
ast_set_flag(&buddy->flags, AJI_AUTOREGISTER);
ASTOBJ_UNLOCK(buddy);
if (buddy) {
ASTOBJ_CONTAINER_LINK(&client->buddies, buddy);
@@ -2618,7 +2618,7 @@ static int aji_create_client(char *label, struct ast_variable *var, int debug)
/* Set default values for the client object */
client->debug = debug;
ast_copy_flags(client, &globalflags, AST_FLAGS_ALL);
ast_copy_flags(&client->flags, &globalflags, AST_FLAGS_ALL);
client->port = 5222;
client->usetls = 1;
client->usesasl = 1;
@@ -2663,9 +2663,9 @@ static int aji_create_client(char *label, struct ast_variable *var, int debug)
else if (!strcasecmp(var->name, "keepalive"))
client->keepalive = (ast_false(var->value)) ? 0 : 1;
else if (!strcasecmp(var->name, "autoprune"))
ast_set2_flag(client, ast_true(var->value), AJI_AUTOPRUNE);
ast_set2_flag(&client->flags, ast_true(var->value), AJI_AUTOPRUNE);
else if (!strcasecmp(var->name, "autoregister"))
ast_set2_flag(client, ast_true(var->value), AJI_AUTOREGISTER);
ast_set2_flag(&client->flags, ast_true(var->value), AJI_AUTOREGISTER);
else if (!strcasecmp(var->name, "buddy"))
aji_create_buddy((char *)var->value, client);
else if (!strcasecmp(var->name, "priority"))