aMSN Forums
October 17, 2018, 09:34:29 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: New forum for aMSN !!
 
   Home   Help Search Login Register  
Pages: [1] 2 3 ... 21
  Print  
Author Topic: Winks pluggin, a little work  (Read 278114 times)
Zaskar
Super Power User
**
Offline Offline

Posts: 159


View Profile
« on: December 31, 2006, 09:01:46 pm »

===================================================    
   Here is the last version: http://in.solit.us/archives/download/16486
===================================================

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Now, here begins the original first post:

Hi, I'm working in something like a winks plugin. At the moment, I can send some winks. That's what I do: I ask for a file (that file is the .cab file that must be extracted from the .mco file, that is a cab itself), then I prepare an msnobj to send (code stolen from protocol.tcl, but with some modifications), and finally cut it into many chuks and send each chunk with its header. Some winks work in that way (like kiss, frog or guitar smash), but many others don't. I'm trying to figure out why. But I see with a sniffer that when msn 7.0 send the kiss I receive 3 chunks, but sending in that way requieres about 15 chunks. Does anyone know why is that difference? What should I be sending instead of that file? You can see that the message for the kiss is hardcoded for the rigth click event as an example.
The code (very very dirty, be patience) is here. You will also need to add a line like:
   ::MSN::setClientCap winks
in load_config in config.tcl (how can I do this from the plugin?) and two pictures (pixmaps/winksbut_hover.png and winksbut.png).

Code:


namespace eval ::winks {
proc Init { dir } {
::plugins::RegisterPlugin "Winks"
::plugins::RegisterEvent "Winks" chatwindowbutton AddWinksButton
::skin::setPixmap butwinks winksbut.png pixmaps [file join $dir pixmaps]
::skin::setPixmap butwinks_hover winksbut_hover.png pixmaps [file join $dir pixmaps]
}


proc AddWinksButton { event evpar } {
upvar 2 $evpar newvar

set buttonbar $newvar(bottom)

set winksbut $buttonbar.winksbut
label $winksbut -image [::skin::loadPixmap butwinks] -relief flat -padx 0 \
-background [::skin::getKey buttonbarbg] -highlightthickness 0 -borderwidth 0 \
-highlightbackground [::skin::getKey buttonbarbg] -activebackground [::skin::getKey buttonbarbg]
pack $winksbut -side left -padx 0 -pady 0

set window $newvar(window_name)

bind $winksbut <<Button3>> "after 1 ::winks::send_via_queue $newvar(window_name)"
bind $winksbut <<Button1>> "after 1 ::winks::send_wink $newvar(window_name)"
bind $winksbut  <Enter> "$winksbut configure -image [::skin::loadPixmap butwinks_hover]"
bind $winksbut  <Leave> "$winksbut configure -image [::skin::loadPixmap butwinks]"
}


proc log {message} {
plugins_log Winks $message
}


proc send_wink {window_name} {

set chatid [::ChatWindow::Name $window_name]

set filename [chooseFileDialog]

set sbn [::MSN::SBFor $chatid]

set Creator [::config::getKey login]
set type 8

#MSNOBJECT

global msnobjcontext

if { [file exists $filename] == 0 } { return "" }
set fd [open $filename r]
fconfigure $fd -translation binary
set data [read $fd]
close $fd

set file $filename
set size [string length $data]
set sha1d [::base64::encode [binary format H* [::sha1::sha1 $data]]]
set sha1c [::base64::encode [binary format H* [::sha1::sha1 "Creator${Creator}Size${size}Type${type}Location${file}.tmpFriendlyAAA=SHA1D${sha1d}"]]]


# SEND CHUNCKS
set maxchars 1202

set sb [::MSN::SBFor $chatid]
if { $sb == 0 } {
return
}

set fd [open $file r]
fconfigure $fd -translation {binary binary}
set data [read $fd]
close $fd

set data [::base64::encode $data]
set data [string map { "\n" ""} $data]
set data "ID: 2\r\nData: <msnobj Creator=\"$Creator\" Size=\"$size\" Type=\"$type\" Location=\"[urlencode $file].tmp\" Friendly=\"AAA=\" SHA1D=\"$sha1d\" SHA1C=\"$sha1c\" stamp=\"$data\"/>\r\n\r\n"
set chunks [expr {int( [string length $data] / $maxchars) + 1 } ]


status_log "Wink data : $data\nchunks : $chunks\n"

for {set i 0 } { $i < $chunks } { incr i } {
set chunk [string range $data [expr $i * $maxchars] [expr ($i * $maxchars) + $maxchars - 1]]
set msg ""
if { $i == 0 } {
set msg "MIME-Version: 1.0\r\nContent-Type: text/x-msnmsgr-datacast\r\n"
if { $chunks == 1 } {
set msg "${msg}\r\n$chunk"
} else {
set msgid "[format %X [myRand 4369 65450]][format %X [myRand 4369 65450]]-[format %X [myRand 4369 65450]]-[format %X [myRand 4369 65450]]-[format %X [expr { int([expr {rand() * 1000000}])%65450 } ] + 4369]-[format %X [myRand 4369 65450]][format %X [myRand 4369 65450]][format %X [myRand 4369 65450]]"
set msg "${msg}Message-ID: \{$msgid\}\r\nChunks: $chunks\r\n\r\n$chunk"
}
} else {
set msg "${msg}Message-ID: \{$msgid\}\r\nChunk: $i\r\n\r\n$chunk"
}
set msglen [string length $msg]

::MSN::WriteSBNoNL $sbn "MSG" "U $msglen\r\n$msg"

}



#MINE
amsn::WinWrite $chatid "\n[timestamp] A wink was send to [::abook::getDisplayNick $chatid]." green

}

proc send_via_queue {window_name} {
set chatid [::ChatWindow::Name $window_name]
::MSN::ChatQueue $chatid [list ::winks::SendWink $window_name]
}
proc SendWink {window_name} {

#Find the SB
set chatid [::ChatWindow::Name $window_name]
::winks::log "\nStart sending winks to <[::abook::getDisplayNick $chatid]>\n"

::winks::SendPackets $chatid
}

proc SendPackets {chatid} {
set sbn [::MSN::SBFor $chatid]

#Write the packet

set msg  "MIME-Version: 1.0\r\nContent-Type: text/x-msnmsgr-datacast\r\nMessage-ID: {E9754E2A-DE52-4C43-9925-7321B478467B}\r\nChunks: 3\r\n\r\nID: 2\r\nData: <msnobj Creator=\"zaskar_@hotmail.com\" Size=\"10224\" Type=\"8\" Location=\"TFR2A.dat\" Friendly=\"QgBlAHMAbwAAAA==\" SHA1D=\"alxGH/FbmTzeLEdtRHmv6GBUzdw=\" SHA1C=\"KISfavcHuWaQdiqEXHauRljIHSc=\" stamp=\"MIIInQYJKoZIhvcNAQcCoIIIjjCCCIoCAQExCzAJBgUrDgMCGgUAMCwGCSqGSIb3DQEHAaAfBB1hbHhHSC9GYm1UemVMRWR0UkhtdjZHQlV6ZHc9UKCCBrQwggawMIIFmKADAgECAgoFFrAoAAEAAAAJMA0GCSqGSIb3DQEBBQUAMHwxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24xJjAkBgNVBAMTHU1TTiBDb250ZW50IEF1dGhlbnRpY2F0aW9uIENBMB4XDTA1MDIyNTE4MDM0OFoXDTA1MDMxNTE4MTM0OFowUTESMBAGA1UEChMJTWljcm9zb2Z0MQwwCgYDVQQLEwNNU04xLTArBgNVBAMTJDZhMjRkMTEwLWM2YmQtNDc2Ni1iMGNkLTU4YTBlMzc5NDlhNzCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA0NIN35EKdW/q7ZaDI7IasI6m0T/ta19mxTBsyBA6C10NZ7TRM86QXw5WisYKBxS3jbupgo2D5hTHd4c7MStRM0efUgJDLTyzM7Kojem+FF16FYgEYaOeI2pSFZhP5I731B0k5jRwzMpQ6wlKg86diKv8PFUwOiOws41gfjCymvcCAwEAAaOCA+EwggPdMB0GA1UdDgQWBBTyHJ1dnGaT1pVQmP/YelVTNvYmMTAfBgNVHSUEGDAWBggrBgEFBQcDCAYKKwYBBAGCNzMBAzCCAksGA1UdIASCAkIwggI+MIICOgYJKwYBBAGCNxUvMIICKzBJBggrBgEFBQcCARY9aHR0cHM6Ly93d3cubWljcm9zb2Z0LmNvbS9wa2kvc3NsL2Nwcy9NaWNyb3NvZnRNU05Db250ZW50Lmh0bTCCAdwGCCsGAQUFBwICMIIBzh6CAcoATQBpAGMAcgBvAH"
set msg_len [string length $msg]
::MSN::WriteSBNoNL $sbn "MSG" "U $msg_len\r\n$msg"

set msg  "Message-ID: {E9754E2A-DE52-4C43-9925-7321B478467B}\r\nChunk: 1\r\n\r\nMAbwBmAHQAIABkAG8AZQBzACAAbgBvAHQAIAB3AGEAcgByAGEAbgB0ACAAbwByACAAYwBsAGEAaQBtACAAdABoAGEAdAAgAHQAaABlACAAaQBuAGYAbwByAG0AYQB0AGkAbwBuACAAZABpAHMAcABsAGEAeQBlAGQAIABpAG4AIAB0AGgAaQBzACAAYwBlAHIAdABpAGYAaQBjAGEAdABlACAAaQBzACAAYwB1AHIAcgBlAG4AdAAgAG8AcgAgAGEAYwBjAHUAcgBhAHQAZQAsACAAbgBvAHIAIABkAG8AZQBzACAAaQB0ACAAbQBhAGsAZQAgAGEAbgB5ACAAZgBvAHIAbQBhAGwAIABzAHQAYQB0AGUAbQBlAG4AdABzACAAYQBiAG8AdQB0ACAAdABoAGUAIABxAHUAYQBsAGkAdAB5ACAAbwByACAAcwBhAGYAZQB0AHkAIABvAGYAIABkAGEAdABhACAAcwBpAGcAbgBlAGQAIAB3AGkAdABoACAAdABoAGUAIABjAG8AcgByAGUAcwBwAG8AbgBkAGkAbgBnACAAcAByAGkAdgBhAHQAZQAgAGsAZQB5AC4AIDALBgNVHQ8EBAMCB4AwgaEGA1UdIwSBmTCBloAUdeBjdZAOPzN4/ah2f6tTCLPcC+qhcqRwMG4xCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24xGDAWBgNVBAMTD01TTiBDb250ZW50IFBDQYIKYQlx2AABAAAABTBLBgNVHR8ERDBCMECgPqA8hjpodHRwOi8vY3JsLm1pY3Jvc29mdC5jb20vcGtpL2NybC9wcm9kdWN0cy9NU05Db250ZW50Q0EuY3JsME4GCCsGAQUFBwEBBEIwQDA+BggrBgEFBQcwAoYyaHR0cDovL3d3dy5taWNyb3NvZnQuY29tL3BraS9jZXJ0L01TTkNvbnRlbnRDQS5jcnQwDQYJKoZIhvcNAQEFBQADggEBAHDQBEIIaOolQ2dE9BH/5LHdW9r+j2kW5n77eXxVimhSVKrFSPzTSjAdtSt0Co+88nXpcJABZq+v1sIVQLFh79hJyyXes1tokNE4aqdpsI6/Eqzrfs5LtTxPmGqxPTP5EaEKQTlC"
set msg_len [string length $msg]
::MSN::WriteSBNoNL $sbn "MSG" "U $msg_len\r\n$msg"


set msg  "Message-ID: {E9754E2A-DE52-4C43-9925-7321B478467B}\r\nChunk: 2\r\n\r\nX1S7j2hosLAumG6SvrCNWpqNDXk34ZOzMfJkxBAHK85QTzX7vEgQWkCCygS88VkqXO78L2bFk5vw/vxhqfSBskEmn35U3apsEfzJTm4QPpE+WveskYLZUkg3PTMEpS+53+ZnvAk40rbzJhhdO8lfFCL4RNU9igYa8TiRznuxQ7Fq+PclPGUVa7onZafyGy1zMbIgKWiWX7A5TqIxggGQMIIBjAIBATCBijB8MQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9uZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMSYwJAYDVQQDEx1NU04gQ29udGVudCBBdXRoZW50aWNhdGlvbiBDQQIKBRawKAABAAAACTAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMDUwMzA3MjAxMjI2WjAjBgkqhkiG9w0BCQQxFgQUCSImtwu6i2GnKmxSZ2lqK5bOXEgwDQYJKoZIhvcNAQEBBQAEgYCfqODRDkr0yl3y0BJtVSw/i3lbscq6IGlIu91qmxd15tus8aMmCn31u+Gr/LjOa5u9GowtkNGtsCbp9o0F4yvAQLPHNGkK4YboTvqpXxsn9oUwnwXx3OoUzF2LSSIl4FxxZbrpXln1yFCbMFkUZI72QwyNHwLOCHQ4NTioI1WaGA==\"/>\r\n\r\n"
set msg_len [string length $msg]
::MSN::WriteSBNoNL $sbn "MSG" "U $msg_len\r\n$msg"

amsn::WinWrite $chatid "\n[timestamp] A kiss was send to [::abook::getDisplayNick $chatid]." green

return

}

proc SendButtonPressed { window } {
global HOME
set filename [chooseFileDialog]
if { $filename != "" } {
if { [info exists ::env(TEMP) ] } {
if {[catch {::picture::Convert $filename [file join $::env(TEMP) "inktosend.gif"]} res]} {
msg_box $res
return
}
::amsn::InkSend $window [file join $::env(TEMP) "inktosend.gif"]
} else {
if {[catch {::picture::Convert $filename [file join "/tmp" "inktosend.gif"]} res]} {
msg_box $res
return
}
::amsn::InkSend $window [file join /tmp "inktosend.gif"]
}
}
}
}




Code:

<?xml version="1.0"?>
<plugin>
<name>Winks</name>
<author>Pablo Novara and others ;) (some code taken from Nudge plugin, some from amsn's protocol, ...)</author>
<description>Winks!!!!!.</description>
<amsn_version>0.95</amsn_version>
<plugin_version>0.1</plugin_version>
<plugin_file>winks.tcl</plugin_file>
<plugin_namespace>winks</plugin_namespace>
<init_procedure>Init</init_procedure>
</plugin>


Again, it's really very dirty, there's missing many things (some of them easy to code, others I don't know) some menu for the button (something like bigsmileys menu with the pngs that comes in the cab file), it should check that the other client supports winks before sending, should receive winks (see if any msnobj is type 8, extract the file and play the swf with some external configurable player), etc; but that's my first day of working on it, and I'll wait for ideas or suggestions, or anything.

Another question: Where can I upload periodically a zip file for testing instead of pasting so many code here?

P.S.: Happy New Year for everyone!!!
Logged
Kalinda
Power user
*
Offline Offline

Posts: 97


View Profile
« Reply #1 on: January 01, 2007, 03:48:15 am »

Ooo; cool! Thanks! Of course, I lack the understanding to use it as is.. buut.. I believe it belongs in the SVN, you need to be a delveoper to access it. Perhaps you could upload it someplace like sendspace or yousendit? Or if you have web space...

I suppose I could host it for you, since I have webspace. Upload it to one of the above and I'll upload it to my server. Unless you can somehow get it into the SVN.. Use kate_baggins@yahoo.ca for yousendit.com

Happy New Year to you, too! Thanks for this!
Logged
NoWhereMan
Contributor
Super Power User
**
Offline Offline

Posts: 502



View Profile
« Reply #2 on: January 01, 2007, 11:30:13 am »

here's some ideas http://www.amsn-project.net/forums/viewtopic.php?p=13643#13643
good job Smiley
Logged

NoWhereMan
-- Windows mom: «Finish your veggies! There are processes in Ubuntu that are starving to death!»
-- NoWhereBlog (ita)
-- http://flatpress.sf.net
Zaskar
Super Power User
**
Offline Offline

Posts: 159


View Profile
« Reply #3 on: January 01, 2007, 07:39:38 pm »

Now I can "receive" some winks. The code I have sees if there's any wink message, strips the wink's cab from the msnobj and write that content into a file. This file should be open with some tools like cabextract and gnash for example (I'll wotk on this later). But again the same trouble: when you send the winks that comes with msn7 they don't send the cab file, they send something instead that I still don't know what it is (the magic command "file" says just data). If someone knows something else about that will be welcome... That's the new code:

Code:


proc Init { dir } {
...
::plugins::RegisterEvent Winks chatwindowbutton AddWinksButton
::plugins::RegisterEvent Winks DataCastPacketReceived received
...
}


proc received { event evpar } {
upvar 2 $evpar args
upvar 2 $args(chatid) chatid
upvar 2 $args(nick) nick
upvar 2 $args(msg) msg

set header "[$msg getHeader Content-Type]"
set ID "[$msg getField ID]"

if {$header == "text/x-msnmsgr-datacast" && $ID == "2"} {

amsn::WinWrite $chatid "\n[timestamp] A wink was received from [::abook::getDisplayNick $chatid]. \n" green


#get the msnobj
set data [$msg getBody]

# extract the stamp field from the msnobj
set stamp [split $data " "]
set idx [lsearch $stamp "stamp=*"]
set stamp [lindex $stamp $idx]
set stamp [string range $stamp 7 end-7]

#amsn::WinWrite $chatid "\n STAMP: $stamp \n" green

set data [::base64::decode $stamp]

set filename "/wink/2/booga"
set fileId [open $filename "w"]
fconfigure $fileId -translation binary
puts -nonewline $fileId $data
close $fileId

}

}


Is there any programmer reading that??? I'm learning tcl on the way, so it's not the best code, but works for the moment.
Logged
Zaskar
Super Power User
**
Offline Offline

Posts: 159


View Profile
« Reply #4 on: January 02, 2007, 12:45:45 am »

Ok, here's what I found till now (I'm writting everything here because I don't know if someone else is working in something like this):

I have many .mco files, that are really .cab files that contains two files inside: One is another .cab (usually named TFXXX.cab) that contains the little tumbnail (little image, png), a content.xml with some properties from the .swf (name, size, version, etc) and the .swf. The other one is a content.xml that containt the cab name, a stamp field, a other things, like a field saying if the content is or not public. Note that there are two content.xml. The first one is inside the .mco gile, the second one is inside the .cab file.

For sending a wink, we should send a message with an msnobj preceded by a line "ID: 2" and the word "Data: ". The msnobj shold say "8" in the "type" field, and include the wink name encoded with base64 int the "friendly" field, the .cab file name in the "file" field and at the end an extra field called "stamp" that contains the stamp field that we see in the first "content.xml"... I'm experimenting with it now.
But, if we put in the stamp file, instead of that, the whole .cab file encoded with base64 and the other side client knows the wink, it works. The trouble is that in that way we send many more chunks thant in the first one.

For receiving winks, we intercept any msnobj, see if the type field says 8, extract the stamp, decode with base64 and then: if that's the cab file, extract content.xml and the swf and reproduce with some external player. If not, that's when we receive the true stamp field (the most common way), I still don't know what to do.


Googling for wink's protocol, I read that the stamp is like a signature for the wink. When the client get the message, looks for the wink in its cache, and if it's not there, ask for it (the cab file).

About the code, my plugin at this moment can send winks in the long (not good) way; there some bugs for sending them in the correct one, but I'm working on it, and when reciving it just tells you the wink's name and if it contain the whole cab, put it into a file.


That's all what... I'll continue reading and doing tests. If there's someone who have a better idea about how it works or how it should be done will be welcome.
Logged
Zaskar
Super Power User
**
Offline Offline

Posts: 159


View Profile
« Reply #5 on: January 02, 2007, 08:15:59 am »

Here's my little progress:
For sending: that code will ask for a file, that is the .mco file. It will decompress it in a temp folder (replace "/wink/tmp" for something better") using cabextract and read the content.xml file for makin the msnobj. Then the msnobj will be sent and if the other client knows the wink (that is, the wink is one of the standards or is in chache) it will play it. If the other client doesn't know the wink, will send an invite message asking for it (the TFxxx.cab). I still don't know how to response the invite, can anyone put a little light on it? (I'm reading protocol.tcl and msnp2p.tcl).
For receiving: it gets the msnobject, strips the wink name and show a message. It should use the sha1d to compare with the winks in cache (there's no wink's cache yet) and if it's not there ask for the cab file using an invite message (that doesn't work yet). Again, any suggestion?

About setting the clientcap, its solved. About using an external player, I've test many winks with gnash and they work ok.


Code:

namespace eval ::winks {
proc Init { dir } {
::MSN::setClientCap winks
::plugins::RegisterPlugin Winks
::plugins::RegisterEvent Winks chatwindowbutton AddWinksButton
::plugins::RegisterEvent Winks DataCastPacketReceived received
::plugins::RegisterEvent Winks PacketReceived received
::skin::setPixmap butwinks winksbut.png pixmaps [file join $dir pixmaps]
::skin::setPixmap butwinks_hover winksbut_hover.png pixmaps [file join $dir pixmaps]
}


proc AddWinksButton { event evpar } {
upvar 2 $evpar newvar

set buttonbar $newvar(bottom)

set winksbut $buttonbar.winksbut
label $winksbut -image [::skin::loadPixmap butwinks] -relief flat -padx 0 \
-background [::skin::getKey buttonbarbg] -highlightthickness 0 -borderwidth 0 \
-highlightbackground [::skin::getKey buttonbarbg] -activebackground [::skin::getKey buttonbarbg]
pack $winksbut -side left -padx 0 -pady 0

set window $newvar(window_name)

bind $winksbut <<Button1>> "after 1 ::winks::send_wink $newvar(window_name)"
bind $winksbut  <Enter> "$winksbut configure -image [::skin::loadPixmap butwinks_hover]"
bind $winksbut  <Leave> "$winksbut configure -image [::skin::loadPixmap butwinks]"
}


proc received { event evpar } {
upvar 2 $evpar args
upvar 2 $args(chatid) chatid
upvar 2 $args(nick) nick
upvar 2 $args(msg) msg


set header "[$msg getHeader Content-Type]"
set ID "[$msg getField ID]"

if {$header == "text/x-msnmsgr-datacast" && $ID == "2"} {

#get the msnobj
set data [$msg getBody]
set lista [split $data " "]

# extract the winkname field from the msnobj
set idx [lsearch $lista "Friendly=*"]
set winkname [lindex $lista $idx]
set winkname [string range $winkname 10 end-1]
set winkname [string map {"\x00" ""} [base64::decode $winkname] ]
#set winkname [urldecode $winkname]

# notify in chatwindow
::ChatWindow::MakeFor $chatid
amsn::WinWrite $chatid "\n" green
amsn::WinWriteIcon $chatid greyline 3
amsn::WinWrite $chatid "\n[timestamp] Received wink: \"$winkname\".\n" green
amsn::WinWriteIcon $chatid greyline 3


# extract the stamp field from the msnobj
set idx [lsearch $lista "stamp=*"]
set stamp [lindex $lista $idx]
set stamp [string range $stamp 7 end-7]
set stamp [::base64::decode $stamp]

# extract the sha1d
set idx [lsearch $lista "sha1d=*"]
set sha1d [lindex $lista $idx]
set lista [split $sha1d "\""]
set sha1d [lindex $lista 1]

# extract creator's email
set idx [lsearch $lista "Creator=*"]
set user [lindex $lista $idx]
set lista [split $user "\""]
set user [lindex $lista 1]

#create_dir [file join $HOME winks]

set data [string range $data 13 end-4]

amsn::WinWrite $chatid "\nDATA:$data\n" green

# ask for the cab file?????
::MSNP2P::RequestObjectEx $chatid $user $data "wink"

amsn::WinWrite $chatid "\nAsked for something!\n" green

# write stamp to a file
# set filename "/wink/2/booga"
# set fileId [open $filename "w"]
# fconfigure $fileId -translation binary
# puts -nonewline $fileId $data
# close $fileId

}

}


proc send_wink {window_name} {

set chatid [::ChatWindow::Name $window_name]


set winks_dir "/wink/tmp"
set filename [chooseFileDialog]
set winkname [string map { ".MCO" "" } $filename]

exec "cabextract" "$filename" "-d" "$winks_dir" "-q"
set filename "${winks_dir}/content.xml"


# -----------------------------
#  open and pharse content.xml
# -----------------------------

# read file
if { [file exists $filename] == 0 } {
amsn::WinWrite $chatid "\nCan't open content.xml" red
return ""
}
set fd1 [open $filename r]
set data [read $fd1]
close $fd1

# separate fields
set tmp_list [split $data " "]

# get field "file"
set tmp_idx [lsearch $tmp_list "file=*"]
set tmp_item [lindex $tmp_list $tmp_idx]
set tmp_list_2 [split $tmp_item "\""]
set cabfile [lindex $tmp_list_2 1]

# get field "stamp"
set tmp_idx [lsearch $tmp_list "stamp=*"]
set tmp_item [lindex $tmp_list $tmp_idx]
set tmp_list_2 [split $tmp_item "\""]
set stamp [lindex $tmp_list_2 1]

# ---------------
#  read cab file
# ---------------

# read file
set filename [string map { "content.xml" "" } $filename]
set filename "$filename$cabfile"
if { [file exists $filename] == 0 } {
return ""
amsn::WinWrite $chatid "\nCan't open cab file." red
}
set fd2 [open $filename r]
fconfigure $fd2 -translation binary
set data [read $fd2]
close $fd2


# ------------------
#  build the msnobj
# ------------------

set sbn [::MSN::SBFor $chatid]
set Creator [::config::getKey login]
set type 8
set size [string length $data]

set location $cabfile
set location [urlencode $filename]
# set winkname $???
set friendly [::base64::encode $winkname]

  set sha1d [::base64::encode [binary format H* [::sha1::sha1 $data]]]
set sha1c [::base64::encode [binary format H* [::sha1::sha1 "Creator${Creator}Size${size}Type${type}Location${location}.tmpFriendly${friendly}=SHA1D${sha1d}"]]]


# -------------
#  send chunks
# -------------

set maxchars 1202

set sb [::MSN::SBFor $chatid]
if { $sb == 0 } { return }

set data "ID: 2\r\nData: <msnobj Creator=\"$Creator\" Size=\"$size\" Type=\"$type\" Location=\"$location\" Friendly=\"$friendly\" SHA1D=\"$sha1d\" SHA1C=\"$sha1c\" stamp=\"$stamp\"/>\r\n"

set chunks [expr {int( [string length $data] / $maxchars) + 1 } ]

status_log "Wink data : $data\nchunks : $chunks\n"

for {set i 0 } { $i < $chunks } { incr i } {
set chunk [string range $data [expr $i * $maxchars] [expr ($i * $maxchars) + $maxchars - 1]]
set msg ""
if { $i == 0 } {
set msg "MIME-Version: 1.0\r\nContent-Type: text/x-msnmsgr-datacast\r\n"
if { $chunks == 1 } {
set msg "${msg}\r\n$chunk"
} else {
set msgid "[format %X [myRand 4369 65450]][format %X [myRand 4369 65450]]-[format %X [myRand 4369 65450]]-[format %X [myRand 4369 65450]]-[format %X [expr { int([expr {rand() * 1000000}])%65450 } ] + 4369]-[format %X [myRand 4369 65450]][format %X [myRand 4369 65450]][format %X [myRand 4369 65450]]"
set msg "${msg}Message-ID: \{$msgid\}\r\nChunks: $chunks\r\n\r\n$chunk"
}
} else {
set msg "${msg}Message-ID: \{$msgid\}\r\nChunk: $i\r\n\r\n$chunk"
}
set msglen [string length $msg]

::MSN::WriteSBNoNL $sbn "MSG" "U $msglen\r\n$msg"

}

# -----------------------
#  notify in chat window
# -----------------------

amsn::WinWrite $chatid "\n" green
amsn::WinWriteIcon $chatid greyline 3
amsn::WinWrite $chatid "\n[timestamp] Sent wink: \"$winkname\".\n" green
amsn::WinWriteIcon $chatid greyline 3


}

}
Logged
NoWhereMan
Contributor
Super Power User
**
Offline Offline

Posts: 502



View Profile
« Reply #6 on: January 02, 2007, 11:13:42 am »

wow, you're working hard on it! Smiley
Logged

NoWhereMan
-- Windows mom: «Finish your veggies! There are processes in Ubuntu that are starving to death!»
-- NoWhereBlog (ita)
-- http://flatpress.sf.net
kakaroto
Administrator
Super Power User
*****
Offline Offline

Posts: 9428


View Profile WWW
« Reply #7 on: January 02, 2007, 06:48:04 pm »

Hello, hi there Smiley
Happy to see someone working on winks again. GrdScarabe was working on them but then he got busy and never finished his plugin. I don't know where he is now Sad
sorry if I write a little bit harsh, I don't have much time.
1 - thx for doing this and I hope you'll finish it soon.
2 - you seem to have some reverse engineering skill,s that's cool, how do you like that? Smiley
3 - did you take the time to look at kmess code to see how it's done ?
4 - you could post a zip archive with the winks as .cab files in them, instead of pasting the code here and have no winks to test with
5 - you should use amsn's API a bit more (I know, no docs, you'll have to search for the functions), I think there is already one to create an msnobj, and the most important thing about it is that, when you call create_msnobj, what it does is that, once it generates the msnobj, it will automatically add it to a map table and associate a file with it, so whenever the other user requests that msnobj, amsn will automatically handle it and send the appropriate file.
6 - I see you used :  
Code:

         # ask for the cab file?????
         ::MSNP2P::RequestObjectEx $chatid $user $data "wink"

that's a good API to use, but by specifying "wink", amsn won't recognize that, so when we receive the data, it will not know where to store it, so that could be a problem. if you specify something like "voiceclip" or "bicon" (I think), you'll see the file appear in the voicelips/cache/ or dispalypics/cache/ directories. with "wink", it will be stored nowhere.. hoping it won't cause a bug either... just to let you know...
7 - how it probably works is that, you send the x-msnmsgr-datacast message with the ID and stamp. the stamp is probably some way for M$ to uniquely identify each winks. So you should see if you already received a file with that stamp (looking for a file in winks/${stamp}.cab for example), you use that file, if not, then you request it. I didn't test or anything, but I suppose it's the 'normal' way, you just need to request the msnobj with the msnp2p invite schema...
take a look at how to send a voice clip :
Code:

proc SendVoiceClip {chatid file } {
set sbn [::MSN::SBFor $chatid]
set msnobj [create_msnobj [::config::getKey login] 11 $file]

set msg "MIME-Version: 1.0\r\nContent-Type: text/x-msnmsgr-datacast\r\n\r\nID: 3\r\nData: $msnobj\r\n\r\n"
set msg_len [string length $msg]

#Send the packet
::MSN::WriteSBNoNL $sbn "MSG" "U $msg_len\r\n$msg"

# Let the magic do the rest... (the INVITE will be sent by the other client requesting the msnobj
# created with [create_msnobj] which also links the msnobj to the filename which will be automatically sent)
}

as you can see in msnp2p.tcl, this piece of code explains it all for you. You should probably do the exact same in your plugin. just create the msnobj correctly, send the datacast, and leave the rest to amsn's internals.

8 - you said :
Quote
You will also need to add a line like:
::MSN::setClientCap winks
in load_config in config.tcl (how can I do this from the plugin?) and two pictures (pixmaps/winksbut_hover.png and winksbut.png).

easy to do.. you just need to call that function from the Init proc of your plugin, and call it with the extra 0 argument to unset it in the DeInit proc, this way that setting will change according to who has the plugin loaded and whenever the user loads/unloads the plugin, not only when the config is being read.

I think that's it.. can't remember anything else.
Note that I'm a bit busy and didn't get time to read the whole post, or the code, so if I say something wrong, sorry about that.
Logged

KaKaRoTo
Zaskar
Super Power User
**
Offline Offline

Posts: 159


View Profile
« Reply #8 on: January 03, 2007, 07:53:45 pm »

Hi kakaroto. Thanks for your answer. Finally someone say something.

1) I've just come to post my news and I've just seen your message, so that code doesn't consider what you said. I'll read that now I'll what can be improved.

2) I didn't knew that someone else have been working on winks. I've started all again., my mistake.

3) I've read the kmess code very quickly, and I didn't found anything to obvious. I'll watch it more carefully in these days, I hope.

4) It would be great that someone else test the plugin. Please tell me where to upload it or who should I send it to. I have the code, and some winks (some of them are the standard ones) to test that I've found in the web. I don't know if I can distribute the non standard ones, but they are easy to find googling. Consider that it's not finished yet.

5) The state of the plugin is the following:
   a) There's a menu now (like bigsmiley's one) that let you choose the wink to send by its thumbnail (and you can play it locally as a preview with right click).
   b) You can add a new wink (right click in the wink icon) from an mco file (messenger content object or shomething like this, its just a cab).
   c) You can "send" winks only if the other client knows it.
   d) You can receive the wink message and if you have that wink it will be played, if not, you'll see only its name.
   e) The winks are stored in a folder named "winks" in the $HOME folder (example: /home/zaskar/.amsn/zaskar__hotmail_com/winks). There I make a new folder for every wink called as the cab file, that contains the cab file and its content extracted (three files: .xml, .swf and .png). There's also an index.xml in the winks folder that keeps the names, the stamps, the cab paths, the thumbnail paths, the swf paths, and the sha1ds (that we use to recognize a wink when it comes); and a tmp folder where we extract the temp data (usually the mco's  content.xml).
   g) The config options are three: the flash player (defaul: gnash), the cab extractor (default: cabextract) and a close_on_leave bool that prevent the menu bug in beryl/compiz managers.
Logged
NoWhereMan
Contributor
Super Power User
**
Offline Offline

Posts: 502



View Profile
« Reply #9 on: January 03, 2007, 08:07:14 pm »

http://in.solit.us/ is nice to host files
for a quicker alternative http://www.box.net/lite

bye
Logged

NoWhereMan
-- Windows mom: «Finish your veggies! There are processes in Ubuntu that are starving to death!»
-- NoWhereBlog (ita)
-- http://flatpress.sf.net
Zaskar
Super Power User
**
Offline Offline

Posts: 159


View Profile
« Reply #10 on: January 03, 2007, 08:26:04 pm »

Many thanks kakaroto!!!! I didn't knew that amsn managed in that way msnobjects, now I can send (almost) any wink!!!

About using the api, I had to modify the createmsnobj because I needed to add the stamp field, and modify the friendly field. That's why I say that it's not a clean code at all, but first I want to get it working, then we'll think about cleaning.

About getting the cab file from the other client, I think I can use RequestObject with type "filetransfer" so I can put the cab where I want (and get a cool progress window). Where should I use the filename, I've tried to modify RequestObject and set it in the sessionList parameter, but something goes wrong. I first get an error that says:

can not find channel named "0"
    while executing
"fconfigure $fd -translation {binary binary}"

then, if I ignore that error, the file transfer begin and stop forever in 98%. Any suggestion about amsn internals?

The way it works is by adding those lines

            } elseif {$type == "wink" } {
               create_dir [file join $HOME voiceclips]
               create_dir [file join $HOME voiceclips cache]
               set fd [open "[file join $HOME winks $filename $filename]" w]
            }

and those others

               } elseif { [lindex [SessionList get $cSid] 7] == "wink" } {
                  ::winks::ReceivedWink $chatid $file

in MSNP2P::ReadData just after the voiceclips ones.
Logged
Zaskar
Super Power User
**
Offline Offline

Posts: 159


View Profile
« Reply #11 on: January 04, 2007, 05:12:13 am »

Great news... It's working!!!!. It can send and receive any winks (test needed, but worked for me)...
There's a menu, some configuration for the flash player (tests made with gnash)..., still depends on cabextract (but there are versions for many platforms and is very small), you can add winks, you can keep the winks you receive, etc...

The only problem is that receiving new winks works with the modified protocol.tcl as I said in previous message (thanks again kakaroto for the voiceclip example, some lines of code worths thousands words). How can I solve it??? ¿Any developer over there?

I'll wait for an answer to upload the first beta release... If no one says anything I'll have to upload the protocol.tcl too, at least for testing.

Oh, another little think... If I want to send the wink to contact who has closed the connection (closed the window, or time out), how can open the connection first??? I've tried with chatTo, but it first send the wink and then open the connection, not good.

And a final note: I've just downloaded the beta version of the official standalone flashplayer for linux, looks good (http://labs.adobe.com/downloads/flashplayer9.html)
Logged
NoWhereMan
Contributor
Super Power User
**
Offline Offline

Posts: 502



View Profile
« Reply #12 on: January 04, 2007, 08:24:51 am »

Quote from: "Zaskar"
The only problem is that receiving new winks works with the modified protocol.tcl as I said in previous message (thanks again kakaroto for the voiceclip example, some lines of code worths thousands words). How can I solve it??? ¿Any developer over there?


not really a dev, but are that changes *really* needed? btw
a) you can use tcl rewriting capabilities to rewrite the function right from the plugin itself (see emotes plugin)
b) you can send them a patch diff with svn diff

Quote
h, another little think... If I want to send the wink to contact who has closed the connection (closed the window, or time out), how can open the connection first??? I've tried with chatTo, but it first send the wink and then open the connection, not good.

try seeing what they did for voice clips

Quote
And a final note: I've just downloaded the beta version of the official standalone flashplayer for linux, looks good (http://labs.adobe.com/downloads/flashplayer9.html)


yep Smiley gflashplayer is the standalone
Logged

NoWhereMan
-- Windows mom: «Finish your veggies! There are processes in Ubuntu that are starving to death!»
-- NoWhereBlog (ita)
-- http://flatpress.sf.net
Phil
Administrator
Super Power User
*****
Offline Offline

Posts: 653


View Profile
« Reply #13 on: January 04, 2007, 03:46:38 pm »

These changes are indeed needed : that's not to Zaskar to implement such things...
Moreover, I would say that Winks support shouldn't be in a plugin (at least the receive part)
The only trouble that remain is that your modifications aren't clear...
Could you provide us a patch against the last SVN version ?
(You can do that with a "svn di" command)
Logged

Phil

AMsn is great, and it will be greater :wink:
NoWhereMan
Contributor
Super Power User
**
Offline Offline

Posts: 502



View Profile
« Reply #14 on: January 04, 2007, 04:00:29 pm »

well really it could be a matter of taste; if you want the client to be completely modular you may want to have plugins for everything, so that user can disable what he doesn't need (even the file transfert, which was born as a plugin too)... btw, that's up to you Wink

anyway, great Wink
Logged

NoWhereMan
-- Windows mom: «Finish your veggies! There are processes in Ubuntu that are starving to death!»
-- NoWhereBlog (ita)
-- http://flatpress.sf.net
Pages: [1] 2 3 ... 21
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!