Hi Zaskar,
Can you please read correctly our posts before answering. Vivia said that you need to modify your plugin and to use events!
no, msnp2p.tcl is not yet patched on SVN, that's because vivia asked you to send the new diff with the PostEvent being called. You do understand that with your current patch, if someone sends us a wink and that your plugin is not loaded, then we'll get a bug like
"::winks::ReceivedWink" command does not exist
.
Anyways, I just committed some changes.. I want you to work with THAT code from SVN version 7719. Here's the diff :
Index: msnp2p.tcl
===================================================================
--- msnp2p.tcl (revision 7718)
+++ msnp2p.tcl (working copy)
@@ -954,6 +954,12 @@
status_log "VOICE: file <$file> does not exist" red
}
+ } elseif { [lindex [SessionList get $cSid] 7] == "wink" } {
+ # Winks support is not in the core, all we can do is support it in the msnp2p code
+ # and launch an event for an appropriate plugin to manage it.
+ set evPar(chatid) chatid
+ set evPar(filename) [file join $HOME winks cache ${filename}.mco]
+ ::plugins::PostEvent WinkReceived evPar
} elseif { [lindex [SessionList get $cSid] 7] == "filetransfer" } {
# Display message that file transfer is finished...
status_log "MSNP2P | $cSid -> File transfer finished!\n"
@@ -991,6 +997,8 @@
create_dir [file join $HOME voiceclips]
create_dir [file join $HOME voiceclips cache]
set fd [open "[file join $HOME voiceclips cache ${filename}.wav]" w]
+ } elseif {$type == "wink" } {
+ set fd [open "[file join $HOME winks cache ${filename}.mco]" w]
}
fconfigure $fd -translation {binary binary}
Index: protocol.tcl
===================================================================
--- protocol.tcl (revision 7718)
+++ protocol.tcl (working copy)
@@ -6414,7 +6414,7 @@
}
-proc create_msnobj { Creator type filename } {
+proc create_msnobj { Creator type filename {friendly "AAA="} {stamp ""}} {
global msnobjcontext
if { [file exists $filename] == 0 } { return "" }
@@ -6429,10 +6429,16 @@
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}"]]]
+ set sha1c [::base64::encode [binary format H* [::sha1::sha1 "Creator${Creator}Size${size}Type${type}Location${file}.tmpFriendly${friendly}SHA1D${sha1d}"]]]
- set msnobj "<msnobj Creator=\"$Creator\" Size=\"$size\" Type=\"$type\" Location=\"[urlencode $file].tmp\" Friendly=\"AAA=\" SHA1D=\"$sha1d\" SHA1C=\"$sha1c\"/>"
+ set msnobj "<msnobj Creator=\"$Creator\" Size=\"$size\" Type=\"$type\" Location=\"[urlencode $file].tmp\" Friendly=\"${friendly}\" SHA1D=\"$sha1d\" SHA1C=\"$sha1c\""
+ if { $stamp == "" } {
+ append msnobj "/>"
+ } else {
+ append msnobj " stamp=\"$stamp\"/>"
+ }
+
set msnobjcontext($msnobj) $filename
return $msnobj
I want you to explicitely use THAT code and make your plugin work with THAT code. your plugin needs to be modified.
First, you must NOT rewrite any of the current procs into your own plugin, what if we ever change the way it works now, huh ? for example in create_msnobj, what if we suddenly change the msnobjcontext into a namespace variable instead of a global variable, then your plugin won't work anymore. So you have to always use our functions, not rewrite them just because you need a little change.
Also note that you rewrote RequestObject in order to specify a filename.. THIS IS WRONG! you must let amsn use the filename it has set internally, you shouldn't override that! once the wink is received you'll get a WinkReceived event being fired with the filename being in there, you should use that and don't rename the file!
The "Location" field of the msnobj is not important at all, it's only the filename of the temp file from the other user's machine, which means we can very easily get many different users with different winks which have the same Location. This is why you should just ignore it, it's only informational, and you shouldn't use that to store the wink into. I also noticed that you request the msnobj without the stamp field (very hacky way to do it btw), why is that ? I would be surprised if you said that it won't work with the stamp in the msnobj.
Also, why did you write the file to $HOME/winks/$cfile/$cfile" ? why twice $cfile ? this is wrong.
I've been looking very briefly at your code, and I know it was hacky, but you can't say that the plugin is finished with code as hacky as it is right now. Please clean it up as much as you can before releasing the plugin.
Amongst other things to clean, I noticed you used "$HOME/winks" in some places for example. NEVER do something like that, what would happen on windows where the separator is the other way around, huh? you must do [file join $HOME winks] instead.
Also, you say you can specify which program to use to extract the cab file. it's false, you can only specify "the path to cabextrat" because you use cabextract specific options to extract the file, if we put the path to 7zip for example, it will just say that it doesn't recognize the options. Also, you use many texts in there without translations. I suggest you translate the text.
Please clean your code, remove the CreateObject and RequestObject from your plugin and use the latest SVN version to make the plugin work against it.
I'll have to review your code later as this seems to be a mess even though it's working.
thx