Changeset 609
- Timestamp:
- 07/23/05 16:19:31 (3 years ago)
- Files:
-
- trunk/src/requests.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/requests.c
r497 r609 98 98 99 99 100 int request_io_handler(GIOChannel *source,GIOCondition condition,gpointer data){101 Request *r;102 User *u;103 GIOCondition cond;104 int res=0;105 106 r=(Request *)data;107 g_assert(r!=NULL);108 109 u=user_get_by_jid(r->from);110 user_load_locale(u);111 112 if (r->gghttp){113 if (r->gghttp->callback)114 res=r->gghttp->callback(r->gghttp);115 else116 res=gg_http_watch_fd(r->gghttp);117 }118 119 switch(r->type){120 case RT_PASSWD:121 if (res || r->gghttp->state==GG_STATE_ERROR) change_password_error(r);122 else if (!res && r->gghttp->state==GG_STATE_DONE) change_password_done(r);123 else break;124 r->io_watch=0;125 remove_request(r);126 return FALSE;127 128 default:129 g_warning(N_("Unknow gg_http session type: %i"),r->gghttp->type);130 gg_http_watch_fd(r->gghttp);131 break;132 }133 134 cond=G_IO_ERR|G_IO_HUP|G_IO_NVAL;135 if (r->gghttp->check&GG_CHECK_READ) cond|=G_IO_IN;136 if (r->gghttp->check&GG_CHECK_WRITE) cond|=G_IO_OUT;137 r->io_watch=g_io_add_watch(r->ioch,cond,request_io_handler,r);138 139 return FALSE;140 }141 142 100 Request * add_request(RequestType type,const char *from,const char *to, 143 101 const char *id,xmlnode query, void *data, … … 145 103 Request *r; 146 104 Session *s; 147 GIOCondition cond;148 struct gg_http *gghttp;149 105 150 106 r=g_new0(Request,1); … … 158 114 r->stream=stream; 159 115 160 if (type==RT_VCARD || type==RT_SEARCH || type==RT_CHANGE){116 if (type==RT_VCARD || type==RT_SEARCH || type==RT_CHANGE) { 161 117 s=session_get_by_jid(from, stream,0); 162 118 if (s==NULL) return NULL; … … 166 122 gg_pubdir50(s->ggs, (gg_pubdir50_t)data); 167 123 g_hash_table_insert(lookups, &r->hash, r); 168 }169 else{170 gghttp=(struct gg_http*)data;171 172 r->gghttp=gghttp;173 174 r->ioch=g_io_channel_unix_new(gghttp->fd);175 cond=G_IO_ERR|G_IO_HUP|G_IO_NVAL;176 if (r->gghttp->check&GG_CHECK_READ) cond|=G_IO_IN;177 if (r->gghttp->check&GG_CHECK_WRITE) cond|=G_IO_OUT;178 r->io_watch=g_io_add_watch(r->ioch,cond,request_io_handler,r);179 124 } 180 125 requests=g_list_append(requests,r); … … 186 131 if (!r) return -1; 187 132 requests=g_list_remove(requests,r); 188 if (r->io_watch) g_source_remove(r->io_watch);189 if (r->type!=RT_VCARD && r->type!=RT_SEARCH){190 g_io_channel_close(r->ioch);191 }192 133 if (r->from) g_free(r->from); 193 134 if (r->to) g_free(r->to);
