/* * EXPORTED FUNCTIONS */ static gboolean plugin_load(PurplePlugin *plugin) { MySetLayeredWindowAttributes = (void*) wpurple_find_and_loadproc( "user32.dll", "SetLayeredWindowAttributes"); if (!MySetLayeredWindowAttributes) { purple_debug_error(WINTRANS_PLUGIN_ID, "SetLayeredWindowAttributes API not found (Required W2K+)\n"); return FALSE; } purple_signal_connect(purple_conversations_get_handle(), "conversation-created", plugin, PURPLE_CALLBACK(new_conversation_cb), NULL); /* Set callback to remove window from the list, if the window is destroyed */ purple_signal_connect(purple_conversations_get_handle(), "deleting-conversation", plugin, PURPLE_CALLBACK(conversation_delete_cb), NULL); purple_signal_connect(pidgin_conversations_get_handle(), "conversation-dragging", plugin, PURPLE_CALLBACK(set_conv_window_trans), NULL); purple_signal_connect(purple_conversations_get_handle(), "conversation-updated", plugin, PURPLE_CALLBACK(conv_updated_cb), NULL); update_existing_convs(); if (blist) blist_created_cb(NULL, NULL); else purple_signal_connect(pidgin_blist_get_handle(), "gtkblist-created", plugin, PURPLE_CALLBACK(blist_created_cb), NULL); return TRUE; }
PurpleSrvQueryData * purple_srv_resolve(const char *protocol, const char *transport, const char *domain, PurpleSrvCallback cb, gpointer extradata) { char *query; PurpleSrvQueryData *query_data; #ifndef _WIN32 int in[2], out[2]; int pid; #else GError* err = NULL; static gboolean initialized = FALSE; #endif query = g_strdup_printf("_%s._%s.%s", protocol, transport, domain); purple_debug_info("dnssrv","querying SRV record for %s\n", query); #ifndef _WIN32 if(pipe(in) || pipe(out)) { purple_debug_error("dnssrv", "Could not create pipe\n"); g_free(query); cb(NULL, 0, extradata); return NULL; } pid = fork(); if (pid == -1) { purple_debug_error("dnssrv", "Could not create process!\n"); cb(NULL, 0, extradata); g_free(query); return NULL; } /* Child */ if (pid == 0) { close(out[0]); close(in[1]); resolve(in[0], out[1]); } close(out[1]); close(in[0]); if (write(in[1], query, strlen(query)+1) < 0) purple_debug_error("dnssrv", "Could not write to SRV resolver\n"); query_data = g_new0(PurpleSrvQueryData, 1); query_data->cb = cb; query_data->extradata = extradata; query_data->pid = pid; query_data->handle = purple_input_add(out[0], PURPLE_INPUT_READ, resolved, query_data); g_free(query); return query_data; #else if (!initialized) { MyDnsQuery_UTF8 = (void*) wpurple_find_and_loadproc("dnsapi.dll", "DnsQuery_UTF8"); MyDnsRecordListFree = (void*) wpurple_find_and_loadproc( "dnsapi.dll", "DnsRecordListFree"); initialized = TRUE; } query_data = g_new0(PurpleSrvQueryData, 1); query_data->cb = cb; query_data->query = query; query_data->extradata = extradata; if (!MyDnsQuery_UTF8 || !MyDnsRecordListFree) query_data->error_message = g_strdup("System missing DNS API (Requires W2K+)\n"); else { query_data->resolver = g_thread_create(res_thread, query_data, FALSE, &err); if (query_data->resolver == NULL) { query_data->error_message = g_strdup_printf("SRV thread create failure: %s\n", (err && err->message) ? err->message : ""); g_error_free(err); } } /* The query isn't going to happen, so finish the SRV lookup now. * Asynchronously call the callback since stuff may not expect * the callback to be called before this returns */ if (query_data->error_message != NULL) query_data->handle = g_idle_add(res_main_thread_cb, query_data); return query_data; #endif }
gboolean dns_sd_available(void) { #ifndef LINK_DNS_SD_DIRECTLY static gboolean initialized = FALSE; static gboolean loaded = FALSE; if (!initialized) { initialized = TRUE; if ((_DNSServiceAddRecord = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceAddRecord")) && (_DNSServiceBrowse = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceBrowse")) && (_DNSServiceConstructFullName = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceConstructFullName")) && (_DNSServiceProcessResult = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceProcessResult")) && (_DNSServiceQueryRecord = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceQueryRecord")) && (_DNSServiceRefDeallocate = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceRefDeallocate")) && (_DNSServiceRefSockFD = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceRefSockFD")) && (_DNSServiceRegister = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceRegister")) && (_DNSServiceResolve = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceResolve")) && (_DNSServiceRemoveRecord = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceRemoveRecord")) && (_DNSServiceUpdateRecord = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceUpdateRecord")) && (_TXTRecordCreate = (void *) wpurple_find_and_loadproc("dnssd.dll", "TXTRecordCreate")) && (_TXTRecordDeallocate = (void *) wpurple_find_and_loadproc("dnssd.dll", "TXTRecordDeallocate")) && (_TXTRecordGetBytesPtr = (void *) wpurple_find_and_loadproc("dnssd.dll", "TXTRecordGetBytesPtr")) && (_TXTRecordGetLength = (void *) wpurple_find_and_loadproc("dnssd.dll", "TXTRecordGetLength")) && (_TXTRecordGetValuePtr = (void *) wpurple_find_and_loadproc("dnssd.dll", "TXTRecordGetValuePtr")) && (_TXTRecordSetValue = (void *) wpurple_find_and_loadproc("dnssd.dll", "TXTRecordSetValue"))) { loaded = TRUE; } } return loaded; #else return TRUE; #endif }