gboolean sipe_certificate_init(struct sipe_core_private *sipe_private)
{
	struct sipe_certificate *sc;
	struct sipe_cert_crypto *ssc;

	if (sipe_private->certificate)
		return(TRUE);

	ssc = sipe_cert_crypto_init();
	if (!ssc) {
		SIPE_DEBUG_ERROR_NOFORMAT("sipe_certificate_init: crypto backend init FAILED!");
		return(FALSE);
	}

	sc = g_new0(struct sipe_certificate, 1);
	sc->certificates = g_hash_table_new_full(g_str_hash, g_str_equal,
						 g_free,
						 sipe_cert_crypto_destroy);
	sc->backend = ssc;

	SIPE_DEBUG_INFO_NOFORMAT("sipe_certificate_init: DONE");

	sipe_private->certificate = sc;
	return(TRUE);
}
예제 #2
0
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;
}
예제 #3
0
void sipe_xml_free(sipe_xml *node)
{
	sipe_xml *child;

	if (!node) return;

	/* we don't support partial tree deletion */
	if (node->parent != NULL) {
		SIPE_DEBUG_ERROR_NOFORMAT("sipe_xml_free: partial delete attempt! Expect crash or memory leaks...");
	}

	/* free children */
	child = node->first;
	while (child) {
		sipe_xml *tmp = child->sibling;
		child->parent = NULL; /* detach from tree, see above */
		sipe_xml_free(child);
		child = tmp;
	}

	/* free node */
	g_free(node->name);
	if (node->data)       g_string_free(node->data, TRUE);
	if (node->attributes) g_hash_table_destroy(node->attributes);
	g_free(node);
}
예제 #4
0
static void
ensure_codecs_conf()
{
	gchar *filename;
	filename = g_build_filename(purple_user_dir(), "fs-codec.conf", NULL);

	if (!g_file_test(filename, G_FILE_TEST_EXISTS)) {
		int fd = g_open(filename, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
		gchar *fs_codecs_conf = FS_CODECS_CONF;
		if ((fd < 0) || write(fd, fs_codecs_conf, strlen(fs_codecs_conf)) == -1)
			SIPE_DEBUG_ERROR_NOFORMAT("Can not create fs-codec.conf!");
		if (fd >= 0)
			close(fd);
	}

	g_free(filename);
}
static void read_completed(GObject *stream,
			   GAsyncResult *result,
			   gpointer data)
{
	struct sipe_transport_telepathy *transport = data;
	struct sipe_transport_connection *conn = SIPE_TRANSPORT_CONNECTION;

	do {
		if (conn->buffer_length < conn->buffer_used + BUFFER_SIZE_INCREMENT) {
			conn->buffer_length += BUFFER_SIZE_INCREMENT;
			conn->buffer = g_realloc(conn->buffer, conn->buffer_length);
			SIPE_DEBUG_INFO("read_completed: new buffer length %" G_GSIZE_FORMAT,
					conn->buffer_length);
		}

		/* callback result is valid */
		if (result) {
			GError *error = NULL;
			gssize len    = g_input_stream_read_finish(G_INPUT_STREAM(stream),
								   result,
								   &error);

			if (len < 0) {
				const gchar *msg = error ? error->message : "UNKNOWN";
				SIPE_DEBUG_ERROR("read_completed: error: %s", msg);
				if (transport->error)
					transport->error(conn, msg);
				g_error_free(error);
				return;
			} else if (len == 0) {
				SIPE_DEBUG_ERROR_NOFORMAT("read_completed: server has disconnected");
				transport->error(conn, _("Server has disconnected"));
				return;
			} else if (transport->do_flush) {
				/* read completed while disconnected transport is flushing */
				SIPE_DEBUG_INFO_NOFORMAT("read_completed: ignored during flushing");
				return;
			} else if (g_cancellable_is_cancelled(transport->cancel)) {
				/* read completed when transport was disconnected */
				SIPE_DEBUG_INFO_NOFORMAT("read_completed: cancelled");
				return;
			}

			/* Forward data to core */
			conn->buffer_used               += len;
			conn->buffer[conn->buffer_used]  = '\0';
			transport->input(conn);

			/* we processed the result */
			result = NULL;
		}

		/* buffer too short? */
	} while (conn->buffer_length - conn->buffer_used - 1 == 0);

	/* setup next read */
	g_input_stream_read_async(G_INPUT_STREAM(stream),
				  conn->buffer + conn->buffer_used,
				  conn->buffer_length - conn->buffer_used - 1,
				  G_PRIORITY_DEFAULT,
				  transport->cancel,
				  read_completed,
				  transport);
}
예제 #6
0
struct sipe_backend_chat_session *sipe_backend_chat_create(struct sipe_core_public *sipe_public,
							   struct sipe_chat_session *session,
							   const gchar *title,
							   const gchar *nick)
{
	SIPPROTO *pr = sipe_public->backend_private;
	GCSESSION gs;
	GCDEST gcd = {0};
	GCEVENT gce = {0};
	gchar *id = g_strdup(title); /* FIXME: Generate ID */
	struct sipe_backend_chat_session *conv = g_new0(struct sipe_backend_chat_session,1);

	gs.cbSize = sizeof(gs);
	gs.iType = GCW_CHATROOM;
	gs.pszModule = pr->proto.m_szModuleName;
	gs.pszName = title;
	gs.pszID = id;
	gs.pszStatusbarText = NULL;
	gs.dwFlags = 0;
	gs.dwItemData = (DWORD)session;

	if (CallServiceSync( MS_GC_NEWSESSION, 0, (LPARAM)&gs ))
	{
		SIPE_DEBUG_ERROR("Failed to create chat session <%d> <%s>", id, title);
	}

	gcd.pszModule = pr->proto.m_szModuleName;
	gcd.pszID = id;

	gce.cbSize = sizeof(gce);
	gce.pDest = &gcd;

	gcd.iType = GC_EVENT_ADDGROUP;
	gce.pszStatus = "Normal";
	if (CallService( MS_GC_EVENT, 0, (LPARAM)&gce ))
	{
		SIPE_DEBUG_WARNING_NOFORMAT("Failed to add normal status to chat session");
	}

	gce.pszStatus = "Presenter";
	if (CallService( MS_GC_EVENT, 0, (LPARAM)&gce ))
	{
		SIPE_DEBUG_WARNING_NOFORMAT("Failed to add presenter status to chat session");
	}


	gcd.iType = GC_EVENT_CONTROL;

	if (CallServiceSync( MS_GC_EVENT, SESSION_INITDONE, (LPARAM)&gce ))
	{
		SIPE_DEBUG_WARNING_NOFORMAT("Failed to initdone chat session");
	}
	if (CallServiceSync( MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce ))
	{
		SIPE_DEBUG_ERROR_NOFORMAT("Failed to set chat session online");
	}

	conv->conv = id;
	conv->pr = pr;

	return conv;
}