unsigned long sip_sec_init_context_step(SipSecContext context, const char *target, const char *input_toked_base64, char **output_toked_base64, int *expires) { sip_uint32 ret = SIP_SEC_E_INTERNAL_ERROR; if (context) { SipSecBuffer in_buff = {0, NULL}; SipSecBuffer out_buff = {0, NULL}; char *tmp; /* Not NULL for NTLM Type 2 */ if (input_toked_base64) { in_buff.value = g_base64_decode(input_toked_base64, &in_buff.length); tmp = sip_sec_ntlm_message_describe(in_buff); if (tmp) { SIPE_DEBUG_INFO("sip_sec_init_context_step: Challenge message is:\n%s", tmp); } g_free(tmp); } ret = (*context->init_context_func)(context, in_buff, &out_buff, target); if (input_toked_base64) g_free(in_buff.value); if (ret == SIP_SEC_E_OK || ret == SIP_SEC_I_CONTINUE_NEEDED) { *output_toked_base64 = g_base64_encode(out_buff.value, out_buff.length); if (out_buff.length > 0 && out_buff.value) { tmp = sip_sec_ntlm_message_describe(out_buff); if (tmp) { SIPE_DEBUG_INFO("sip_sec_init_context_step: Negotiate or Authenticate message is:\n%s", tmp); } g_free(tmp); } g_free(out_buff.value); } if (expires) { *expires = context->expires; } } return ret; }
void sipe_process_imdn(struct sipe_core_private *sipe_private, struct sipmsg *msg) { gchar *with = parse_from(sipmsg_find_header(msg, "From")); const gchar *callid = sipmsg_find_header(msg, "Call-ID"); static struct sip_session *session; sipe_xml *xn_imdn; const sipe_xml *node; gchar *message_id; gchar *message; session = sipe_session_find_chat_or_im(sipe_private, callid, with); if (!session) { SIPE_DEBUG_INFO("sipe_process_imdn: unable to find conf session with callid=%s", callid); g_free(with); return; } xn_imdn = sipe_xml_parse(msg->body, msg->bodylen); message_id = sipe_xml_data(sipe_xml_child(xn_imdn, "message-id")); message = g_hash_table_lookup(session->conf_unconfirmed_messages, message_id); /* recipient */ for (node = sipe_xml_child(xn_imdn, "recipient"); node; node = sipe_xml_twin(node)) { gchar *tmp = parse_from(sipe_xml_attribute(node, "uri")); gchar *uri = parse_from(tmp); gchar *status = sipe_xml_data(sipe_xml_child(node, "status")); guint error = status ? g_ascii_strtoull(status, NULL, 10) : 0; /* default to error if missing or conversion failed */ if ((error == 0) || (error >= 300)) sipe_user_present_message_undelivered(sipe_private, session, error, -1, uri, message); g_free(status); g_free(tmp); g_free(uri); } sipe_xml_free(xn_imdn); g_hash_table_remove(session->conf_unconfirmed_messages, message_id); SIPE_DEBUG_INFO("sipe_process_imdn: removed message %s from conf_unconfirmed_messages(count=%d)", message_id, g_hash_table_size(session->conf_unconfirmed_messages)); g_free(message_id); g_free(with); }
static void get_and_publish_cert(struct sipe_core_private *sipe_private, const gchar *uri, SIPE_UNUSED_PARAMETER const gchar *raw, sipe_xml *soap_body, gpointer callback_data) { struct certificate_callback_data *ccd = callback_data; gboolean success = (uri == NULL); /* abort case */ if (soap_body) { gchar *cert_base64 = sipe_xml_data(sipe_xml_child(soap_body, "Body/GetAndPublishCertResponse/RequestSecurityTokenResponse/RequestedSecurityToken/BinarySecurityToken")); SIPE_DEBUG_INFO("get_and_publish_cert: received valid SOAP message from service %s", uri); if (cert_base64) { gpointer opaque = sipe_cert_crypto_decode(sipe_private->certificate->backend, cert_base64); SIPE_DEBUG_INFO_NOFORMAT("get_and_publish_cert: found certificate"); if (opaque) { add_certificate(sipe_private, ccd->target, opaque); SIPE_DEBUG_INFO("get_and_publish_cert: certificate for target '%s' added", ccd->target); /* Let's try this again... */ sip_transport_authentication_completed(sipe_private); success = TRUE; } g_free(cert_base64); } } if (!success) { certificate_failure(sipe_private, _("Certificate request to %s failed"), uri, NULL); } callback_data_free(ccd); }
struct sip_session * sipe_core_conf_create(struct sipe_core_public *sipe_public, const gchar *uri) { gchar *uri_ue = sipe_utils_uri_unescape(uri); gchar *focus_uri; struct sip_session *session = NULL; SIPE_DEBUG_INFO("sipe_core_conf_create: URI '%s' unescaped '%s'", uri ? uri : "<UNDEFINED>", uri_ue ? uri_ue : "<UNDEFINED>"); focus_uri = parse_ocs_focus_uri(uri_ue); if (!focus_uri) { focus_uri = parse_lync_join_url(uri_ue); } if (focus_uri) { session = sipe_conf_create(SIPE_CORE_PRIVATE, NULL, focus_uri); g_free(focus_uri); } else { gchar *error = g_strdup_printf(_("\"%s\" is not a valid conference URI"), uri ? uri : ""); sipe_backend_notify_error(sipe_public, _("Failed to join the conference"), error); g_free(error); } g_free(uri_ue); return session; }
/** * Removes header if it's not in keepers array */ void sipmsg_strip_headers(struct sipmsg *msg, const gchar *keepers[]) { GSList *entry; struct sipnameval *elem; entry = msg->headers; while(entry) { int i = 0; gboolean keeper = FALSE; elem = entry->data; while (keepers[i]) { if (!g_strcasecmp(elem->name, keepers[i])) { keeper = TRUE; break; } i++; } if (!keeper) { GSList *to_delete = entry; SIPE_DEBUG_INFO("sipmsg_strip_headers: removing %s", elem->name); entry = g_slist_next(entry); msg->headers = g_slist_delete_link(msg->headers, to_delete); g_free(elem->name); g_free(elem->value); g_free(elem); } else { entry = g_slist_next(entry); } } }
gboolean sipe_backend_chat_find(struct sipe_backend_chat_session *backend_session, const gchar *uri) { SIPPROTO *pr = backend_session->pr; GC_INFO gci = {0}; gchar *context; const gchar *user; gci.Flags = BYID | USERS; gci.pszID = mir_a2t(backend_session->conv); gci.pszModule = pr->proto.m_szModuleName; if(CallServiceSync( MS_GC_GETINFO, 0, (LPARAM)&gci )) { SIPE_DEBUG_ERROR_NOFORMAT("Failed to get chat user list"); return FALSE; } if (!gci.pszUsers) return FALSE; user = strtok_s(gci.pszUsers, " ", &context); while (user) { SIPE_DEBUG_INFO("sipe_backend_chat_find: Found user <%s>", user); if (!strcmp(uri, user)) { mir_free(gci.pszUsers); return TRUE; } user = strtok_s(NULL, " ", &context); } mir_free(gci.pszUsers); return FALSE; }
static void dns_a_response(GObject *resolver, GAsyncResult *result, gpointer data) { GError *error = NULL; GList *addresses = g_resolver_lookup_by_name_finish(G_RESOLVER(resolver), result, &error); struct sipe_dns_query *query = data; if (addresses) { GInetAddress *address = addresses->data; gchar *ipstr = g_inet_address_to_string(address); query->callback(query->extradata, ipstr, query->port); g_free(ipstr); g_resolver_free_addresses(addresses); } else { SIPE_DEBUG_INFO("dns_a_response: failed: %s", error ? error->message : "UNKNOWN"); g_error_free(error); if (query->callback) query->callback(query->extradata, NULL, 0); } g_object_unref(query->cancel); g_free(query); }
struct sipe_dns_query *sipe_backend_dns_query_srv(SIPE_UNUSED_PARAMETER struct sipe_core_public *sipe_public, const gchar *protocol, const gchar *transport, const gchar *domain, sipe_dns_resolved_cb callback, gpointer data) { struct sipe_dns_query *query = g_new0(struct sipe_dns_query, 1); GResolver *resolver = g_resolver_get_default(); SIPE_DEBUG_INFO("sipe_backend_dns_query_srv: %s/%s/%s", protocol, transport, domain); query->callback = callback; query->extradata = data; query->cancel = g_cancellable_new(); g_resolver_lookup_service_async(resolver, protocol, transport, domain, query->cancel, dns_srv_response, query); g_object_unref(resolver); return(query); }
static void dns_srv_response(GObject *resolver, GAsyncResult *result, gpointer data) { GError *error = NULL; GList *targets = g_resolver_lookup_service_finish(G_RESOLVER(resolver), result, &error); struct sipe_dns_query *query = data; if (targets) { GSrvTarget *target = targets->data; query->callback(query->extradata, g_srv_target_get_hostname(target), g_srv_target_get_port(target)); g_resolver_free_targets(targets); } else { SIPE_DEBUG_INFO("dns_srv_response: failed: %s", error ? error->message : "UNKNOWN"); g_error_free(error); if (query->callback) query->callback(query->extradata, NULL, 0); } g_object_unref(query->cancel); g_free(query); }
static char * sipe_domino_get_free_busy(time_t fb_start, GSList *cal_events) { GSList *entry = cal_events; char *res; if (!cal_events) return NULL; res = g_strnfill(SIPE_FREE_BUSY_PERIOD_SEC / SIPE_FREE_BUSY_GRANULARITY_SEC, SIPE_CAL_FREE + '0'); while (entry) { struct sipe_cal_event *cal_event = entry->data; int start = sipe_domino_get_slot_no(fb_start, cal_event->start_time); int end = sipe_domino_get_slot_no(fb_start, (cal_event->end_time - 1)); int i; for (i = start; i <= end; i++) { res[i] = SIPE_CAL_BUSY + '0'; } entry = entry->next; } SIPE_DEBUG_INFO("sipe_domino_get_free_busy: res=\n%s", res); return res; }
struct sipe_group *sipe_group_add(struct sipe_core_private *sipe_private, const gchar *name, const gchar *exchange_key, const gchar *change_key, guint id) { struct sipe_group *group = NULL; if (!is_empty(name)) { group = sipe_group_find_by_name(sipe_private, name); if (!group && sipe_backend_buddy_group_add(SIPE_CORE_PUBLIC, name)) { group = g_new0(struct sipe_group, 1); group->name = g_strdup(name); group->id = id; if (exchange_key) group->exchange_key = g_strdup(exchange_key); if (change_key) group->change_key = g_strdup(change_key); sipe_private->groups->list = g_slist_append(sipe_private->groups->list, group); SIPE_DEBUG_INFO("sipe_group_add: created backend group '%s' with id %d", group->name, group->id); } else {
void sipe_backend_chat_remove(struct sipe_backend_chat_session *backend_session, const gchar *uri) { SIPPROTO *pr = backend_session->pr; struct sipe_core_public *sipe_public = pr->sip; gchar *self = sipe_miranda_uri_self(pr); GCDEST gcd = {0}; GCEVENT gce = {0}; HANDLE hContact = sipe_backend_buddy_find( sipe_public, uri, NULL ); gchar *nick = sipe_miranda_getContactString(pr, hContact, "Nick"); SIPE_DEBUG_INFO("sipe_backend_chat_remove: Removing user <%s> from chat <%s>", uri, backend_session->conv); gcd.pszModule = pr->proto.m_szModuleName; gcd.pszID = backend_session->conv; gcd.iType = GC_EVENT_PART; gce.cbSize = sizeof(gce); gce.pDest = &gcd; gce.pszNick = nick; gce.pszUID = uri; gce.pszStatus = 0; gce.bIsMe = !strcmp(self, uri); g_free(self); CallService( MS_GC_EVENT, 0, (LPARAM)&gce ); mir_free(nick); }
void sipe_backend_chat_add(struct sipe_backend_chat_session *backend_session, const gchar *uri, gboolean is_new) { SIPPROTO *pr = backend_session->pr; struct sipe_core_public *sipe_public = pr->sip; gchar *self = sipe_miranda_uri_self(pr); GCDEST gcd = {0}; GCEVENT gce = {0}; int retval; HANDLE hContact = sipe_backend_buddy_find( sipe_public, uri, NULL ); gchar *nick = sipe_miranda_getContactString(pr, hContact, "Nick"); SIPE_DEBUG_INFO("sipe_backend_chat_add: Adding user <%s> to chat <%s>", uri, backend_session->conv); gcd.pszModule = pr->proto.m_szModuleName; gcd.pszID = backend_session->conv; gcd.iType = GC_EVENT_JOIN; gce.cbSize = sizeof(gce); gce.pDest = &gcd; gce.pszNick = nick; gce.pszUID = uri; gce.pszStatus = "Normal"; gce.bIsMe = !strcmp(self, uri); g_free(self); retval = CallService( MS_GC_EVENT, 0, (LPARAM)&gce ); if (retval) { SIPE_DEBUG_WARNING("sipe_backend_chat_add: Failed to add user to chat: <%d>", retval); } mir_free(nick); }
void sipe_mime_parts_foreach(const gchar *type, const gchar *body, sipe_mime_parts_cb callback, gpointer user_data) { gchar *doc = g_strdup_printf("Content-Type: %s\r\n\r\n%s", type, body); GMimeStream *stream = g_mime_stream_mem_new_with_buffer(doc, strlen(doc)); if (stream) { GMimeParser *parser = g_mime_parser_new_with_stream(stream); GMimeMultipart *multipart = (GMimeMultipart *)g_mime_parser_construct_part(parser); if (multipart) { struct gmime_callback_data cd = {callback, user_data}; SIPE_DEBUG_INFO("sipe_mime_parts_foreach: %d parts", g_mime_multipart_get_count(multipart)); g_mime_multipart_foreach(multipart, gmime_callback, &cd); g_object_unref(multipart); } g_object_unref(parser); g_object_unref(stream); } g_free(doc); }
void process_incoming_invite_conf(struct sipe_core_private *sipe_private, struct sipmsg *msg) { sipe_xml *xn_conferencing = sipe_xml_parse(msg->body, msg->bodylen); const sipe_xml *xn_focus_uri = sipe_xml_child(xn_conferencing, "focus-uri"); const sipe_xml *xn_audio = sipe_xml_child(xn_conferencing, "audio"); gchar *focus_uri = sipe_xml_data(xn_focus_uri); gboolean audio = sipe_strequal(sipe_xml_attribute(xn_audio, "available"), "true"); sipe_xml_free(xn_conferencing); SIPE_DEBUG_INFO("We have received invitation to Conference. Focus URI=%s", focus_uri); if (audio) { sip_transport_response(sipe_private, msg, 180, "Ringing", NULL); ask_accept_voice_conference(sipe_private, focus_uri, msg, (SipeUserAskCb) conf_accept_cb, (SipeUserAskCb) conf_decline_cb); } else { accept_incoming_invite_conf(sipe_private, focus_uri, FALSE, msg); } g_free(focus_uri); }
/** Create conference callback */ static gboolean process_conf_add_response(struct sipe_core_private *sipe_private, struct sipmsg *msg, struct transaction *trans) { if (msg->response >= 400) { SIPE_DEBUG_INFO_NOFORMAT("process_conf_add_response: SERVICE response is not 200. Failed to create conference."); /* @TODO notify user of failure to create conference */ return FALSE; } if (msg->response == 200) { sipe_xml *xn_response = sipe_xml_parse(msg->body, msg->bodylen); if (sipe_strequal("success", sipe_xml_attribute(xn_response, "code"))) { gchar *who = trans->payload->data; const sipe_xml *xn_conference_info = sipe_xml_child(xn_response, "addConference/conference-info"); struct sip_session *session = sipe_conf_create(sipe_private, NULL, sipe_xml_attribute(xn_conference_info, "entity")); SIPE_DEBUG_INFO("process_conf_add_response: session->focus_uri=%s", session->chat_session->id); session->pending_invite_queue = sipe_utils_slist_insert_unique_sorted(session->pending_invite_queue, g_strdup(who), (GCompareFunc)strcmp, g_free); } sipe_xml_free(xn_response); } return TRUE; }
static gboolean sip_sec_init_sec_context__tls_dsk(SipSecContext context, SipSecBuffer in_buff, SipSecBuffer *out_buff, SIPE_UNUSED_PARAMETER const gchar *service_name) { context_tls_dsk ctx = (context_tls_dsk) context; struct sipe_tls_state *state = ctx->state; state->in_buffer = in_buff.value; state->in_length = in_buff.length; if (sipe_tls_next(state)) { if ((state->algorithm != SIPE_TLS_DIGEST_ALGORITHM_NONE) && state->client_key && state->server_key) { /* Authentication is completed */ context->flags |= SIP_SEC_FLAG_COMMON_READY; /* copy key pair */ ctx->algorithm = state->algorithm; ctx->key_length = state->key_length; ctx->client_key = g_memdup(state->client_key, state->key_length); ctx->server_key = g_memdup(state->server_key, state->key_length); /* [MS-SIPAE] Section 3.2.2 Timers * * ... For an SA established using the TLS-DSK * authentication protocol, the client MUST * retrieve the expiration time of its certificate. * The expiration timer value is the lesser of the * interval to the certificate expiration and eight * hours, ... */ ctx->common.expires = sipe_tls_expires(state); if (ctx->common.expires > (8 * 60 * 60)) ctx->common.expires = 8 * 60 * 60; SIPE_DEBUG_INFO("sip_sec_init_sec_context__tls_dsk: handshake completed, algorithm %d, key length %" G_GSIZE_FORMAT ", expires %d", ctx->algorithm, ctx->key_length, ctx->common.expires); sipe_tls_free(state); ctx->state = NULL; } else { out_buff->value = state->out_buffer; out_buff->length = state->out_length; /* we take ownership of the buffer */ state->out_buffer = NULL; } } else { sipe_tls_free(state); ctx->state = NULL; } return(((context->flags & SIP_SEC_FLAG_COMMON_READY) || ctx->state)); }
gchar * sipe_chat_get_name(const gchar *proto_chat_id) { /** * A non-volatile mapping of protocol's chat identification * to purple's chat-name. The latter is very important to * find/rejoin chat. * * @key for 2007 conference this is (gchar *) Focus URI * for 2005 multiparty chat this is (gchar *) Call-Id of the conversation. * @value a purple chat name. */ static GHashTable *chat_names = NULL; /** * A non-volatile chat counter. * Should survive protocol reload. */ static int chat_seq = 0; char *chat_name = NULL; if (!chat_names) { chat_names = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); } if (!chat_names_inverse) { chat_names_inverse = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); } if (proto_chat_id) { chat_name = g_hash_table_lookup(chat_names, proto_chat_id); SIPE_DEBUG_INFO("sipe_chat_get_name: lookup results: %s", chat_name ? chat_name : "NULL"); } if (!chat_name) { chat_name = g_strdup_printf(_("Chat #%d"), ++chat_seq); g_hash_table_insert(chat_names, g_strdup(proto_chat_id), chat_name); g_hash_table_insert(chat_names_inverse, chat_name, g_strdup(proto_chat_id)); SIPE_DEBUG_INFO("sipe_chat_get_name: added new: %s", chat_name); } return g_strdup(chat_name); }
static void certificate_result(SIPE_UNUSED_PARAMETER GObject *unused, GAsyncResult *result, gpointer data) { struct sipe_transport_telepathy *transport = data; GError *error = NULL; g_simple_async_result_propagate_error(G_SIMPLE_ASYNC_RESULT(result), &error); if (error) { SIPE_DEBUG_INFO("certificate_result: %s", error->message); if (transport->error) transport->error(SIPE_TRANSPORT_CONNECTION, error->message); g_error_free(error); } else { SIPE_DEBUG_INFO("certificate_result: trigger reconnect %p", transport); g_idle_add(internal_connect, transport); } }
/** * Schedules process of contacts' status update * based on their calendar information. * Should be scheduled to the beginning of every * 15 min interval, like: * 13:00, 13:15, 13:30, 13:45, etc. */ void sipe_ocs2005_schedule_status_update(struct sipe_core_private *sipe_private, time_t calculate_from) { #define SCHEDULE_INTERVAL 15 * 60 /* 15 min */ /* start of the beginning of closest 15 min interval. */ time_t next_start = (calculate_from / SCHEDULE_INTERVAL + 1) * SCHEDULE_INTERVAL; SIPE_DEBUG_INFO("sipe_ocs2005_schedule_status_update: calculate_from time: %s", asctime(localtime(&calculate_from))); SIPE_DEBUG_INFO("sipe_ocs2005_schedule_status_update: next start time : %s", asctime(localtime(&next_start))); sipe_schedule_seconds(sipe_private, "<+2005-cal-status>", NULL, next_start - time(NULL), update_calendar_status, NULL); }
static void on_state_changed_cb(SIPE_UNUSED_PARAMETER PurpleMedia *media, PurpleMediaState state, gchar *sessionid, gchar *participant, struct sipe_media_call *call) { SIPE_DEBUG_INFO("sipe_media_state_changed_cb: %d %s %s\n", state, sessionid, participant); if (state == PURPLE_MEDIA_STATE_END && !sessionid && !participant && call->media_end_cb) call->media_end_cb(call); }
int sipe_miranda_SetStatus( SIPPROTO *pr, int iNewStatus ) { int oldStatus; if (!pr->m_hServerNetlibUser) return 0; if (pr->proto.m_iDesiredStatus == iNewStatus) return 0; oldStatus = pr->proto.m_iStatus; pr->proto.m_iDesiredStatus = iNewStatus; SIPE_DEBUG_INFO("SetStatus: newstatus <%x>", iNewStatus); if (iNewStatus == ID_STATUS_OFFLINE) { pr->disconnecting = TRUE; sipe_miranda_connection_destroy(pr); pr->valid = FALSE; pr->disconnecting = FALSE; } else { if (pr->proto.m_iStatus == ID_STATUS_OFFLINE) { pr->valid = TRUE; pr->state = SIPE_MIRANDA_CONNECTING; pr->proto.m_iStatus = ID_STATUS_CONNECTING; sipe_miranda_SendBroadcast(pr, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, pr->proto.m_iStatus); sipe_miranda_login(pr); } else if (pr->state == SIPE_MIRANDA_CONNECTED) { pr->proto.m_iStatus = pr->proto.m_iDesiredStatus; sipe_miranda_SendBroadcast(pr, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, pr->proto.m_iStatus); LOCK; if (pr->proto.m_iStatus != ID_STATUS_OFFLINE) { gchar *note = sipe_miranda_getString(pr, "note"); sipe_core_status_set(pr->sip, MirandaStatusToSipe(iNewStatus), note); mir_free(note); } UNLOCK; } } /* //Will send an ack with: //type=ACKTYPE_STATUS, result=ACKRESULT_SUCCESS, hProcess=(HANDLE)previousMode, lParam=newMode //when the change completes. This ack is sent for all changes, not just ones //caused by calling this function. //Note that newMode can be ID_STATUS_CONNECTING<=newMode<ID_STATUS_CONNECTING+ //MAX_CONNECT_RETRIES to signify that it's connecting and it's the nth retry. //Protocols are initially always in offline mode. //Non-network-level protocol modules do not have the concept of a status and //should leave this service unimplemented //If a protocol doesn't support the specific status mode, it should pick the */ return 0; }
int sipe_cal_get_status(struct sipe_buddy *buddy, time_t time_in_question, time_t *since) { time_t cal_start; const char* free_busy; int ret = SIPE_CAL_NO_DATA; time_t state_since; int index = -1; if (!buddy || !buddy->cal_start_time || !buddy->cal_granularity) { SIPE_DEBUG_INFO("sipe_cal_get_status: no calendar data1 for %s, exiting", buddy ? (buddy->name ? buddy->name : "") : ""); return SIPE_CAL_NO_DATA; } if (!(free_busy = sipe_cal_get_free_busy(buddy))) { SIPE_DEBUG_INFO("sipe_cal_get_status: no calendar data2 for %s, exiting", buddy->name); return SIPE_CAL_NO_DATA; } SIPE_DEBUG_INFO("sipe_cal_get_description: buddy->cal_free_busy=\n%s", free_busy); cal_start = sipe_utils_str_to_time(buddy->cal_start_time); ret = sipe_cal_get_status0(free_busy, cal_start, buddy->cal_granularity, time_in_question, &index); state_since = sipe_cal_get_since_time(free_busy, cal_start, buddy->cal_granularity, index, ret); if (since) *since = state_since; return ret; }
void sipe_core_init(void) { srand(time(NULL)); sip_sec_init(); #ifdef ENABLE_NLS SIPE_DEBUG_INFO("bindtextdomain = %s", bindtextdomain(PACKAGE_NAME, LOCALEDIR)); SIPE_DEBUG_INFO("bind_textdomain_codeset = %s", bind_textdomain_codeset(PACKAGE_NAME, "UTF-8")); textdomain(PACKAGE_NAME); #endif #ifdef HAVE_NSS if (!NSS_IsInitialized()) { NSS_NoDB_Init("."); SIPE_DEBUG_INFO_NOFORMAT("NSS initialised"); } #endif #ifdef HAVE_GMIME g_mime_init(0); #endif }
static void certprov_webticket(struct sipe_core_private *sipe_private, const gchar *base_uri, const gchar *auth_uri, const gchar *wsse_security, const gchar *failure_msg, gpointer callback_data) { struct certificate_callback_data *ccd = callback_data; if (wsse_security) { /* Got a Web Ticket for Certificate Provisioning Service */ gchar *certreq_base64 = create_certreq(sipe_private, sipe_private->username); SIPE_DEBUG_INFO("certprov_webticket: got ticket for %s", base_uri); if (certreq_base64) { SIPE_DEBUG_INFO_NOFORMAT("certprov_webticket: created certificate request"); if (sipe_svc_get_and_publish_cert(sipe_private, ccd->session, auth_uri, wsse_security, certreq_base64, get_and_publish_cert, ccd)) /* callback data passed down the line */ ccd = NULL; g_free(certreq_base64); } if (ccd) { certificate_failure(sipe_private, _("Certificate request to %s failed"), base_uri, NULL); } } else if (auth_uri) { certificate_failure(sipe_private, _("Web ticket request to %s failed"), base_uri, failure_msg); } if (ccd) callback_data_free(ccd); }
/** Invite us to the focus callback */ static gboolean process_invite_conf_focus_response(struct sipe_core_private *sipe_private, struct sipmsg *msg, SIPE_UNUSED_PARAMETER struct transaction *trans) { struct sip_session *session = NULL; char *focus_uri = parse_from(sipmsg_find_header(msg, "To")); session = sipe_session_find_conference(sipe_private, focus_uri); if (!session) { SIPE_DEBUG_INFO("process_invite_conf_focus_response: unable to find conf session with focus=%s", focus_uri); g_free(focus_uri); return FALSE; } if (!session->focus_dialog) { SIPE_DEBUG_INFO_NOFORMAT("process_invite_conf_focus_response: session's focus_dialog is NULL"); g_free(focus_uri); return FALSE; } sipe_dialog_parse(session->focus_dialog, msg, TRUE); if (msg->response >= 200) { /* send ACK to focus */ session->focus_dialog->cseq = 0; sip_transport_ack(sipe_private, session->focus_dialog); session->focus_dialog->outgoing_invite = NULL; session->focus_dialog->is_established = TRUE; } if (msg->response >= 400) { SIPE_DEBUG_INFO_NOFORMAT("process_invite_conf_focus_response: INVITE response is not 200. Failed to join focus."); /* @TODO notify user of failure to join focus */ sipe_session_remove(sipe_private, session); g_free(focus_uri); return FALSE; } else if (msg->response == 200) { sipe_xml *xn_response = sipe_xml_parse(msg->body, msg->bodylen); const gchar *code = sipe_xml_attribute(xn_response, "code"); if (sipe_strequal(code, "success")) { /* subscribe to focus */ sipe_subscribe_conference(sipe_private, session, FALSE); } sipe_xml_free(xn_response); } g_free(focus_uri); return TRUE; }
void sipe_core_conf_make_leader(struct sipe_core_public *sipe_public, gpointer parameter, const gchar *buddy_name) { struct sipe_core_private *sipe_private = SIPE_CORE_PRIVATE; struct sipe_chat_session *chat_session = parameter; struct sip_session *session; SIPE_DEBUG_INFO("sipe_core_conf_make_leader: chat_title=%s", chat_session->title); session = sipe_session_find_chat(sipe_private, chat_session); sipe_conf_modify_user_role(sipe_private, session, buddy_name); }
void sipe_core_conf_remove_from(struct sipe_core_public *sipe_public, gpointer parameter, const gchar *buddy_name) { struct sipe_core_private *sipe_private = SIPE_CORE_PRIVATE; struct sipe_chat_session *chat_session = parameter; struct sip_session *session; SIPE_DEBUG_INFO("sipe_core_conf_remove_from: chat_title=%s", chat_session->title); session = sipe_session_find_chat(sipe_private, chat_session); sipe_conf_delete_user(sipe_private, session, buddy_name); }
int sip_sec_verify_signature(SipSecContext context, const char *message, const char *signature_hex) { SipSecBuffer signature; sip_uint32 res; SIPE_DEBUG_INFO("sip_sec_verify_signature: message is:%s signature to verify is:%s", message ? message : "", signature_hex ? signature_hex : ""); if (!message || !signature_hex) return SIP_SEC_E_INTERNAL_ERROR; signature.length = hex_str_to_buff(signature_hex, &signature.value); res = (*context->verify_signature_func)(context, message, signature); g_free(signature.value); return res; }
void sipe_purple_set_status(PurpleAccount *account, PurpleStatus *status) { SIPE_DEBUG_INFO("sipe_purple_set_status[CB]: status=%s", purple_status_get_id(status)); if (!purple_status_is_active(status)) return; if (account->gc) { const gchar *status_id = purple_status_get_id(status); const gchar *note = purple_status_get_attr_string(status, SIPE_PURPLE_STATUS_ATTR_ID_MESSAGE); sipe_core_status_set(PURPLE_ACCOUNT_TO_SIPE_CORE_PUBLIC, sipe_purple_token_to_activity(status_id), note); } }