Ticket #409: ink-p2p.patch
| File ink-p2p.patch, 6.8 KB (added by valerio, 3 years ago) |
|---|
-
src/network/applications/inktransferp2p.cpp
20 20 #include "../../kmessdebug.h" 21 21 #include "../mimemessage.h" 22 22 23 #include <QFile> 23 24 24 25 25 /** 26 * The constructor 26 * The constructor to receive Ink messages 27 27 */ 28 28 InkTransferP2P::InkTransferP2P( ApplicationList *applicationList ) 29 29 : P2PApplication( applicationList ) … … 41 41 42 42 43 43 /** 44 * The constructor to send Ink messages 45 */ 46 InkTransferP2P::InkTransferP2P( ApplicationList *applicationList, const QByteArray &inkData ) 47 : P2PApplication( applicationList ) 48 { 49 // Open the buffer directly. 50 // The session is only used to receive data. 51 // inkBuffer_.buffer().prepend( "base64:" ); 52 53 // Set the role / session mode of this class. 54 // Is checked for by the ChatMaster, and P2PApplication base class. 55 setMode( Application::APP_MODE_DATACAST ); 56 setDataCastSessionID( SESSION_ID ); 57 58 59 QByteArray inkData2; 60 61 // This is the user drawn message 62 inkData2 = inkData; 63 // This is the base64 of a valid Ink 64 // inkData2 = "AJIHHAOAgAQdBI4G3AMCIARIEUVkCUgRRICAgARFZAdIEUSAAUVkCEgRRICBAkVkGRQyCACAEAIAAAhCMwgAgAwCAAAEQg8iFauq00GrqtNBAFjVPgCAqr4VAACAPwAAgD8AALnDAEwExh4JH4KD4vjAAAAAChQIh7ZbaFZJJCa7a4T1d6xw4ZxzZAoUC4L8oflFkLqAg/rr675dNcZ3ubAXAQoiCYfvcu8/3lyPnDmcRxwYWvOs/IfyxEeWIm0zPRMAxDatbBcAChUJgv4JA/gkE9XdAIbJWSY6Ulp+XhwKGRKC/gG7+Ab0MTb41dkAgv05+ndqrPF5JY0KGA6C/gIj+AiUGK0AhPgJvgJ5QpK2xO+2tQoZC4L+Auv4C7zclnZQhPgIvgI8Vrasc+HK4AkBChYQgvzl+c4JalSggv29+3/Hhvcu7ly0Cicpgvz5+fc5m7j3L5szJeR2NlWq74gggv21+21hCcux0ZrLLiqZqpQKGxeC/dH7rIThsut7jiiC/en718eJ77K3XeCYAAoXEIL+AHv4AdTSXM0tgv3N+5/Tjvml1IAKEgaD/AJfgE6xPECC/gAD+AAaQAodFoL+AYP4BhcnlLQjONdAgv2t+2Zsk56u93LbdyAKFAmC/gJT+Alec7qgg/rL6z7Vd7uAChEJgv4Cm/gKeS5ogv3Z+72pcAoRCIL+ArP4Cpi2wIL90fuOzQAKIBiD/BdfgtcZtLd8mF1jNzm9AIL9efr2xm54nnaZCL0ACiEdgv4Fk/gWWcy93C0sASkAgv1Z+rc9c897lm29OVk1lKAKGROC/gab+Bp0y2pZNybYgv09+nXrl96pZYAKGBCC/gcb+Bx8sVNlioP6Q+kdVFxcZk1uwAkCChMKgv4H0/gfWXKKgv0Z+i3ObU8gChYRgv4IK/gg2EWWxZsAgv3l+84oVLAACQMKFA6C/gIr+Ai7YRUUgvzt+d0y0SoAChMLgv4CQ/gJXLcWQIL8/fn1JaoAChEKgv4Ca/gJupYAgv0F+g0BQAoTCYL+Anv4CfqDAIL+AUP4BRxUaAoWD4L+Arv4CvLcqVCC/gFT+AVclxu4oAoWDYL+AtP4C1ssoACC/gHL+AcYzzlwzQoXEIL+AuP4C5qVcpFggv4Cc/gJtCSrLQAKGRKC/gL7+Av9zZLLFSwAgv4DA/gL0zVZsFUKGROC/gMT+AxdzZFJYsCC/gOz+A7czTcSqJo=="; 65 66 67 MimeMessage message; 68 message.addField("MIME-Version", "1.0"); 69 message.addField("Content-Type", "image/gif");// kDebug() <<message.getMessage(); 70 // message.addField("Content-Type", "application/x-ms-ink"); 71 message.setBody( "base64:" + inkData2 ); 72 73 QString body( message.getMessage() ); 74 inkBuffer_.setData( QByteArray( (char*)body.utf16(), body.size()*2 ) ); 75 76 sendP2PMessage( inkBuffer_.buffer(), 77 0, 78 P2PApplicationBase::P2P_TYPE_INK, 79 P2PApplicationBase::P2P_MSG_DATA ); 80 } 81 82 83 84 /** 44 85 * The destructor 45 86 */ 46 87 InkTransferP2P::~InkTransferP2P() -
src/network/applications/inktransferp2p.h
29 29 * 30 30 * Windows Live Messenger 8.5 always sends winks as seperate P2P messages instead of directly 31 31 * over the switchboard. It uses image/gif as a mime type. Live Messenger 2009 just uses the 32 * switchboard and uses image/gif or application/x-ms-ink. Both clients allow receiving 32 * switchboard and uses image/gif or application/x-ms-ink. Both clients allow receiving 33 33 * switchboard transfers. 34 34 * 35 35 * @author Antonio Nastasi, Diederik van der Boor … … 43 43 // The fixed session ID used by all ink transfer sessions. 44 44 static const unsigned long SESSION_ID = 64; 45 45 46 // The constructor 46 // The constructor to receive Ink messages 47 47 InkTransferP2P( ApplicationList *applicationList ); 48 // The constructor to send Ink messages 49 InkTransferP2P( ApplicationList *applicationList, const QByteArray &inkData ); 48 50 49 51 // The destructor 50 52 virtual ~InkTransferP2P(); -
src/network/msnswitchboardconnection.cpp
20 20 #include "../contact/contact.h" 21 21 #include "../contact/invitedcontact.h" // for cast 22 22 #include "../contact/msnobject.h" 23 #include "../utils/kmessshared.h" 23 24 #include "../currentaccount.h" 24 25 #include "../emoticonmanager.h" 25 26 #include "../kmessapplication.h" 26 27 #include "../kmessdebug.h" 28 #include "applications/inktransferp2p.h" 27 29 #include "applications/applicationlist.h" 28 30 #include "soap/offlineimservice.h" 29 31 #include "chatinformation.h" … … 1313 1315 { 1314 1316 if( contentType == "text/plain" 1315 1317 || contentType == "text/x-msnmsgr-datacast" 1316 || contentType == "image/gif" 1318 || contentType == "image/gif" 1317 1319 || contentType == "application/x-ms-ink" ) 1318 1320 { 1319 1321 #ifdef KMESSDEBUG_SWITCHBOARD_GENERAL … … 1719 1721 bool capable = true; 1720 1722 ContactBase *contact; 1721 1723 1724 if( contactsInChat_.isEmpty() ) 1725 { 1726 kWarning() << "Can't send Ink to an empty chat."; 1727 return; 1728 } 1729 1722 1730 foreach( const QString &handle, contactsInChat_ ) 1723 1731 { 1724 1732 contact = currentAccount_->getContactByHandle( handle ); … … 1731 1739 } 1732 1740 } 1733 1741 1742 // Testing P2P ink 1743 new InkTransferP2P( contact->getApplicationList(), ink.toBase64() ); 1744 return; 1745 1734 1746 if( ! capable ) 1735 1747 { 1748 #ifdef KMESSDEBUG_SWITCHBOARD_EMOTICONS 1749 kDebug() << "Contact's client is not capable of receiving Ink messages."; 1750 #endif 1736 1751 return; 1737 1752 } 1738 1753 1754 1739 1755 // Create the message for ink 1740 1756 // Source: http://msdn.microsoft.com/en-us/library/ms818340.aspx 1741 1757 // To send the WLM 2009 content-type (maybe ISF): … … 1869 1885 { 1870 1886 if( contentType == "text/plain" 1871 1887 || contentType == "text/x-msnmsgr-datacast" 1872 || contentType == "image/gif" 1888 || contentType == "image/gif" 1873 1889 || contentType == "application/x-ms-ink" ) 1874 1890 { 1875 1891 #ifdef KMESSDEBUG_SWITCHBOARD_GENERAL -
src/network/mimemessage.cpp
60 60 int nullPos = message.indexOf('\0'); 61 61 int endMime = message.indexOf("\r\n\r\n"); 62 62 QString messageHeader( QString::fromUtf8(message.data(), (nullPos == -1) ? endMime : nullPos ) ); 63 kWarning() << messageHeader; 63 64 64 // Regexps to parse the header 65 65 QRegExp rx1("Content-Type: ([A-Za-z0-9$!*/\\-]*)"); 66 66 QRegExp rx2("Message-ID: ([^\r\n]+)");
