| 2397 convo_nofeatures(conv); |
2397 convo_nofeatures(conv); |
| 2398 } |
2398 } |
| 2399 } |
2399 } |
| 2400 |
2400 |
| 2401 |
2401 |
| 2402 #if 0 |
|
| 2403 /** triggered from mw_conversation_opened if the appropriate plugin |
|
| 2404 preference is set. This will open a window for the conversation |
|
| 2405 before the first message is sent. */ |
|
| 2406 static void convo_do_psychic(struct mwConversation *conv) { |
|
| 2407 struct mwServiceIm *srvc; |
|
| 2408 struct mwSession *session; |
|
| 2409 struct mwGaimPluginData *pd; |
|
| 2410 GaimConnection *gc; |
|
| 2411 GaimAccount *acct; |
|
| 2412 |
|
| 2413 struct mwIdBlock *idb; |
|
| 2414 |
|
| 2415 GaimConversation *gconv; |
|
| 2416 GaimConvWindow *win; |
|
| 2417 |
|
| 2418 srvc = mwConversation_getService(conv); |
|
| 2419 session = mwService_getSession(MW_SERVICE(srvc)); |
|
| 2420 pd = mwSession_getClientData(session); |
|
| 2421 gc = pd->gc; |
|
| 2422 acct = gaim_connection_get_account(gc); |
|
| 2423 |
|
| 2424 idb = mwConversation_getTarget(conv); |
|
| 2425 |
|
| 2426 gconv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, |
|
| 2427 idb->user, acct); |
|
| 2428 if(! gconv) { |
|
| 2429 gconv = gaim_conversation_new(GAIM_CONV_TYPE_IM, acct, idb->user); |
|
| 2430 } |
|
| 2431 |
|
| 2432 g_return_if_fail(gconv != NULL); |
|
| 2433 |
|
| 2434 win = gaim_conversation_get_window(gconv); |
|
| 2435 g_return_if_fail(win != NULL); |
|
| 2436 |
|
| 2437 gaim_conv_window_show(win); |
|
| 2438 } |
|
| 2439 #endif |
|
| 2440 |
|
| 2441 |
|
| 2442 static void mw_conversation_opened(struct mwConversation *conv) { |
2402 static void mw_conversation_opened(struct mwConversation *conv) { |
| 2443 struct mwServiceIm *srvc; |
2403 struct mwServiceIm *srvc; |
| 2444 struct mwSession *session; |
2404 struct mwSession *session; |
| 2445 struct mwGaimPluginData *pd; |
2405 struct mwGaimPluginData *pd; |
| 2446 GaimConnection *gc; |
2406 GaimConnection *gc; |
| 3730 const char *fn = gaim_imgstore_get_filename(img); |
3690 const char *fn = gaim_imgstore_get_filename(img); |
| 3731 return g_strdup_printf("attachment; filename=\"%s\"", fn); |
3691 return g_strdup_printf("attachment; filename=\"%s\"", fn); |
| 3732 } |
3692 } |
| 3733 |
3693 |
| 3734 |
3694 |
| 3735 #if NB_HACK |
|
| 3736 static char *nb_im_encode(GaimConnection *gc, const char *message) { |
|
| 3737 GaimAccount *acct; |
|
| 3738 const char *enc; |
|
| 3739 char *ret; |
|
| 3740 GError *error = NULL; |
|
| 3741 |
|
| 3742 acct = gaim_connection_get_account(gc); |
|
| 3743 g_return_val_if_fail(acct != NULL, NULL); |
|
| 3744 |
|
| 3745 enc = gaim_account_get_string(acct, MW_KEY_ENCODING, |
|
| 3746 MW_PLUGIN_DEFAULT_ENCODING); |
|
| 3747 g_return_val_if_fail(enc != NULL, NULL); |
|
| 3748 |
|
| 3749 ret = g_convert_with_fallback(message, strlen(message), |
|
| 3750 enc, "UTF-8", "?", |
|
| 3751 NULL, NULL, &error); |
|
| 3752 |
|
| 3753 if(error) { |
|
| 3754 DEBUG_INFO("problem converting to %s: %s\n", |
|
| 3755 enc, NSTR(error->message)); |
|
| 3756 g_error_free(error); |
|
| 3757 } |
|
| 3758 |
|
| 3759 /* something went so wrong that not even the fallback worked */ |
|
| 3760 if(! ret) ret = g_strdup(message); |
|
| 3761 |
|
| 3762 return ret; |
|
| 3763 } |
|
| 3764 #endif |
|
| 3765 |
|
| 3766 |
|
| 3767 #if NB_HACK |
|
| 3768 static gboolean is_nb(struct mwConversation *conv) { |
|
| 3769 struct mwLoginInfo *info; |
|
| 3770 |
|
| 3771 info = mwConversation_getTargetInfo(conv); |
|
| 3772 if(! info) return FALSE; |
|
| 3773 |
|
| 3774 /* NotesBuddy can be at least three different type IDs (all in the |
|
| 3775 0x1400 range), or it can show up as 0x1000. However, if we're |
|
| 3776 calling this check, then we're already in HTML or MIME mode, so |
|
| 3777 we can discount the real 0x1000 */ |
|
| 3778 /* I tried to avoid having any client-type-dependant code in here, I |
|
| 3779 really did. Oh well. CURSE YOU NOTESBUDDY */ |
|
| 3780 return ((info->type == 0x1000) || ((info->type & 0xff00) == 0x1400)); |
|
| 3781 } |
|
| 3782 #endif |
|
| 3783 |
|
| 3784 |
|
| 3785 /** turn an IM with embedded images into a multi-part mime document */ |
3695 /** turn an IM with embedded images into a multi-part mime document */ |
| 3786 static char *im_mime_convert(GaimConnection *gc, |
3696 static char *im_mime_convert(GaimConnection *gc, |
| 3787 struct mwConversation *conv, |
3697 struct mwConversation *conv, |
| 3788 const char *message) { |
3698 const char *message) { |
| 3789 GString *str; |
3699 GString *str; |
| 3870 |
3780 |
| 3871 /* add the text/html part */ |
3781 /* add the text/html part */ |
| 3872 part = gaim_mime_part_new(doc); |
3782 part = gaim_mime_part_new(doc); |
| 3873 gaim_mime_part_set_field(part, "Content-Disposition", "inline"); |
3783 gaim_mime_part_set_field(part, "Content-Disposition", "inline"); |
| 3874 |
3784 |
| 3875 #if NB_HACK |
|
| 3876 if(is_nb(conv)) { |
|
| 3877 GaimAccount *acct = gaim_connection_get_account(gc); |
|
| 3878 |
|
| 3879 tmp = (char *) gaim_account_get_string(acct, MW_KEY_ENCODING, |
|
| 3880 MW_PLUGIN_DEFAULT_ENCODING); |
|
| 3881 tmp = g_strdup_printf("text/html; charset=\"%s\"", tmp); |
|
| 3882 gaim_mime_part_set_field(part, "Content-Type", tmp); |
|
| 3883 g_free(tmp); |
|
| 3884 |
|
| 3885 gaim_mime_part_set_field(part, "Content-Transfer-Encoding", "7bit"); |
|
| 3886 |
|
| 3887 tmp = nb_im_encode(gc, str->str); |
|
| 3888 gaim_mime_part_set_data(part, tmp); |
|
| 3889 g_free(tmp); |
|
| 3890 |
|
| 3891 } else { |
|
| 3892 gaim_mime_part_set_field(part, "Content-Type", "text/html"); |
|
| 3893 gaim_mime_part_set_field(part, "Content-Transfer-Encoding", "8bit"); |
|
| 3894 gaim_mime_part_set_data(part, str->str); |
|
| 3895 } |
|
| 3896 |
|
| 3897 #else |
|
| 3898 tmp = gaim_utf8_ncr_encode(str->str); |
3785 tmp = gaim_utf8_ncr_encode(str->str); |
| 3899 gaim_mime_part_set_field(part, "Content-Type", "text/html"); |
3786 gaim_mime_part_set_field(part, "Content-Type", "text/html"); |
| 3900 gaim_mime_part_set_field(part, "Content-Transfer-Encoding", "7bit"); |
3787 gaim_mime_part_set_field(part, "Content-Transfer-Encoding", "7bit"); |
| 3901 gaim_mime_part_set_data(part, tmp); |
3788 gaim_mime_part_set_data(part, tmp); |
| 3902 g_free(tmp); |
3789 g_free(tmp); |
| 3903 #endif |
|
| 3904 |
3790 |
| 3905 g_string_free(str, TRUE); |
3791 g_string_free(str, TRUE); |
| 3906 |
3792 |
| 3907 str = g_string_new(NULL); |
3793 str = g_string_new(NULL); |
| 3908 gaim_mime_document_write(doc, str); |
3794 gaim_mime_document_write(doc, str); |
| 3953 g_free(tmp); |
3839 g_free(tmp); |
| 3954 |
3840 |
| 3955 } else if(mwConversation_supports(conv, mwImSend_HTML)) { |
3841 } else if(mwConversation_supports(conv, mwImSend_HTML)) { |
| 3956 /* send an HTML message */ |
3842 /* send an HTML message */ |
| 3957 |
3843 |
| 3958 #if NB_HACK |
|
| 3959 if(is_nb(conv)) { |
|
| 3960 |
|
| 3961 /* html messages need the notesbuddy hack */ |
|
| 3962 char *msg = nb_im_encode(gc, message); |
|
| 3963 tmp = gaim_strdup_withhtml(msg); |
|
| 3964 g_free(msg); |
|
| 3965 |
|
| 3966 } else { |
|
| 3967 /* need to do this to get the \n to <br> conversion */ |
|
| 3968 tmp = gaim_strdup_withhtml(message); |
|
| 3969 } |
|
| 3970 |
|
| 3971 #else |
|
| 3972 char *ncr; |
3844 char *ncr; |
| 3973 ncr = gaim_utf8_ncr_encode(message); |
3845 ncr = gaim_utf8_ncr_encode(message); |
| 3974 tmp = gaim_strdup_withhtml(ncr); |
3846 tmp = gaim_strdup_withhtml(ncr); |
| 3975 g_free(ncr); |
3847 g_free(ncr); |
| 3976 #endif |
|
| 3977 |
3848 |
| 3978 ret = mwConversation_send(conv, mwImSend_HTML, tmp); |
3849 ret = mwConversation_send(conv, mwImSend_HTML, tmp); |
| 3979 g_free(tmp); |
3850 g_free(tmp); |
| 3980 |
3851 |
| 3981 } else { |
3852 } else { |
| 5649 /* port to connect to */ |
5520 /* port to connect to */ |
| 5650 opt = gaim_account_option_int_new(_("Port"), MW_KEY_PORT, |
5521 opt = gaim_account_option_int_new(_("Port"), MW_KEY_PORT, |
| 5651 MW_PLUGIN_DEFAULT_PORT); |
5522 MW_PLUGIN_DEFAULT_PORT); |
| 5652 l = g_list_append(l, opt); |
5523 l = g_list_append(l, opt); |
| 5653 |
5524 |
| 5654 #if NB_HACK |
|
| 5655 /* notesbuddy hack encoding */ |
|
| 5656 opt = gaim_account_option_string_new(_("NotesBuddy encoding"), |
|
| 5657 MW_KEY_ENCODING, |
|
| 5658 MW_PLUGIN_DEFAULT_ENCODING); |
|
| 5659 l = g_list_append(l, opt); |
|
| 5660 #endif |
|
| 5661 |
|
| 5662 { /* copy the old force login setting from prefs if it's |
5525 { /* copy the old force login setting from prefs if it's |
| 5663 there. Don't delete the preference, since there may be more |
5526 there. Don't delete the preference, since there may be more |
| 5664 than one account that wants to check for it. */ |
5527 than one account that wants to check for it. */ |
| 5665 gboolean b = FALSE; |
5528 gboolean b = FALSE; |
| 5666 const char *label = _("Force login (ignore server redirects)"); |
5529 const char *label = _("Force login (ignore server redirects)"); |