Dann auch von mir herzlich Willkommen!!
Ist er hier dabei???
Timm, Nils, Timo, Rene, Lars, Jens, Maik, Meik, Mike, Marc, Mark, Nico, Niko, Eric, Erik, Arne, Dirk, Jörg, Ralf, John, Jörn, Axel, Tino, Andy, Andi, Igor, Falk, Ingo, Lutz, Ivan
Dann auch von mir herzlich Willkommen!!
Ist er hier dabei???
Timm, Nils, Timo, Rene, Lars, Jens, Maik, Meik, Mike, Marc, Mark, Nico, Niko, Eric, Erik, Arne, Dirk, Jörg, Ralf, John, Jörn, Axel, Tino, Andy, Andi, Igor, Falk, Ingo, Lutz, Ivan
Der Text steht in $klasse[0], $charklasse ist nur das Label.
Ich würde $klasse[1] global deklarieren und in Zeile 148 anstatt des Textes angeben.
Sobald du auf Erstellen klickst müsste der aber eigtl angezeigt werden.
Evtl. hat deine Gif ne ähnliche Farbe wie der Text?!
So, oder so ähnlich:
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.0.0
Author: Kev
Script Function:
Template AutoIt script.
#ce ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <Inet.au3>
#include <String.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiComboBox.au3>
#include <array.au3>
#include <file.au3>
#Include <GDIPlus.au3>
#include <Color.au3>
#include <WinAPI.au3>
#include <ScreenCapture.au3>
global $pic1, $draw = 0
Global $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout
$arfile = _FileListToArray (@scriptdir &"\rg_bg\", "*.gif", 1)
$Form1 = Guicreate("Rising Gods Signaturius",680,400)
$shape = GUICtrlCreateInput(' ', 480, 0, 5, 400)
GUICtrlSetBkColor(-1,"0x000000")
Guictrlsetstate(-1,$GUI_DISABLE)
GuictrlcreateLabel("Character Name:",30,30,120,25)
$Name = GUICtrlCreateInput("Dein Charactername",130,25,120,25)
$arfile = _FileListToArray (@scriptdir &"\rg_bg\", "*.gif", 1)
GuictrlcreateLabel("Wähle deine Signatur:",265,30,120,25)
GuictrlcreateLabel("Rising Gods Realm:",30,60,120,25)
$Realm = GUICtrlCreateInput("PvE oder PvP",130,55,120,25)
$Button = GUICtrlCreateButton("Fertig",130,85,120,25)
$ButtonExit = GUICtrlCreateButton("Beenden",550,370,120,25)
$Button1 = GUICtrlCreateButton("Überprüfung",130,112,120,25)
$UpdateButton = GuictrlcreateButton("Update",550,345,120,25)
$SigOK = GuictrlcreateButton("Erstellen",260,85,120,25)
$SigEN = GuictrlcreateButton("Ändern",260,112,120,25)
$Save = GuictrlcreateButton("Signatur speichern",180,165,140,70)
GuiCtrlSetState($SigEN,$GUI_DISABLE)
GuictrlcreateLabel("Character:",500,25,120,25)
GuictrlcreateLabel("Fraktion:",500,55,120,25)
GuictrlcreateLabel("Klasse:",500,85,120,25)
GuictrlcreateLabel("Level:",500,115,120,25)
GuictrlcreateLabel("Rasse:",500,145,120,25)
GuictrlcreateLabel("Skillung:",500,175,120,25)
GuictrlcreateLabel("Gesundheit:",500,205,120,25)
GuictrlcreateLabel("Mana/Wut/Energie:",500,235,120,25)
GuictrlcreateLabel("Gilde:",500,265,120,25)
GuictrlcreateLabel("Erfolgspunkte:",500,295,120,25)
GUICtrlCreateLabel("Programm by Anubiz - GFX by Feyth",150,379,180,90)
Guictrlsetstate(-1,$GUI_DISABLE)
$charklasse = GuictrlcreateLabel("",600,85,120,25)
$charfraktion = GuictrlcreateLabel("",600,55,120,25)
$charname = GuictrlcreateLabel("",600,25,120,25)
$lvl = GuictrlcreateLabel("",600,115,120,25)
$Rasse = GuictrlcreateLabel("",600,145,120,25)
$Skill = GuictrlcreateLabel("",600,175,120,25)
$Gesund = GuictrlcreateLabel("",600,205,120,25)
$Mana = GuictrlcreateLabel("",600,235,120,25)
$guild = GuictrlcreateLabel("",600,265,120,25)
$erfolge = GuictrlcreateLabel("",600,295,120,25)
$Pic1 = GuiCtrlCreatePic("",15,265,450,100,BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Combo1 = Guictrlcreatecombo("",260,55,120,35)
GuiCtrlSetState($Button1, $GUI_DISABLE)
GUISetState(@SW_SHOW)
For $i = 1 To UBound ($arfile) - 1
_GUICtrlComboBox_AddString ($Combo1, $arfile [$i])
Next
_GUICtrlComboBox_SetCurSel ($Combo1, 0)
GUICtrlSetImage ($Pic1, @scriptdir &"\rg_bg\" & $arfile [1])
$value = GUICtrlRead ($Combo1)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
_gdiEnd()
Exit
case $button
GuiCtrlSetState($Name, $GUI_DISABLE)
GuiCtrlSetState($Realm, $GUI_DISABLE)
msgbox(0,"Status", "Character wird abgerufen...")
GuiCtrlSetState($Button1, $GUI_ENABLE)
$source = _INetGetSource("http://www.arsenal.rising-gods.de/character-sheet.xml?r=" & GUICtrlRead($Realm) & "-Realm&n=" & GUICtrlRead($Name))
$klasse = _StringBetween($source, '" class="', '" classId')
If IsArray($klasse) Then GUICtrlSetData($charklasse, $klasse[0])
$faction = _StringBetween($source , '" faction="', '" factionId')
If IsArray($faction) Then GUICtrlSetData($charfraktion, $faction[0])
$name2 = _StringBetween($source , '" name="', '" points')
If IsArray($name2) Then GUICtrlSetData($charname, $name2[0])
$name3 = _StringBetween($source , '" level="', '" name')
If IsArray($name3) Then GUICtrlSetData($lvl, $name3[0])
$name4 = _StringBetween($source , '" race="', '" raceId')
If IsArray($name4) Then GUICtrlSetData($Rasse, $name4[0])
$name5 = _StringBetween($source , '" prim="', '" treeOne')
If IsArray($name5) Then GUICtrlSetData($Skill, $name5[0])
$name6 = _StringBetween($source , '<health effective="', '"/>')
If IsArray($name6) Then GUICtrlSetData($Gesund, $name6[0])
$name7 = _StringBetween($source , '" effective="', '" notCasting')
If IsArray($name7) Then GUICtrlSetData($Mana, $name7[0])
$name8 = _StringBetween($source , '" guildName="', '" guildUrl')
If IsArray($name8) Then GUICtrlSetData($guild, $name8[0])
$name9 = _StringBetween($source , '" points="', '" total')
If IsArray($name9) Then GUICtrlSetData($erfolge, $name9[0])
case $ButtonExit
_gdiEnd()
exit
case $UpdateButton
msgbox(1,"Updater","Nach neuen Updates suchen?")
sleep(1000)
if FileExists (@ScriptDir & "\rg_bg\RG_SigU_01.gif") Then
Msgbox(1,"Updater","Keine neuen Updates vorhanden")
else
InetGet("ftp://username:pass@anubiz.pytalhost.com/RG_SigU_01.gif",@scriptdir & "\rg_bg\RG_SigU_01.gif",1)
InetGet("ftp://username:pass@anubiz.pytalhost.com/RG_SigU_02.gif",@scriptdir & "\rg_bg\RG_SigU_02.gif",1)
sleep(1000)
msgbox(0,"Updater","Update erfolgreich")
Endif
case $SigOK
GuiCtrlSetState($Combo1,$GUI_DISABLE)
GuiCtrlSetState($SigEN,$GUI_ENABLE)
msgbox(0,"Signatur","Signatur erfolgreich ausgewählt")
$draw = 1
_gdiStart(GUICtrlGetHandle($Pic1))
case $SigEN
GuiCtrlSetState($Combo1,$GUI_ENABLE)
case $save
$pic1 = FileSaveDialog("Speichern",@ScriptDir, "JPEG(*.jpg;*.jpeg)|24-Bit-Bitmap(*.bmp)|GIF(*.gif)", 2)
case $Button1
ShellExecute("http://www.arsenal.rising-gods.de/character-sheet.xml?r=" & GUICtrlRead($Realm) & "-Realm&n=" & GUICtrlRead($Name))
EndSwitch
If $value <> GUICtrlRead ($Combo1) Then
GUICtrlSetImage ($Pic1, @scriptdir &"\rg_bg\" & $arfile [_ArraySearch ($arfile, GUICtrlRead ($Combo1))])
$value = GUICtrlRead ($Combo1)
EndIf
If $draw Then _gdiText("Test")
WEnd
Func _gdiStart($hGui)
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI)
$hBrush = _GDIPlus_BrushCreateSolid(0x7F00007F)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
$tLayout = _GDIPlus_RectFCreate(40, 40, 100, 20)
EndFunc
func _gdiText($sText)
_GDIPlus_GraphicsDrawStringEx($hGraphic, $sText, $hFont, $tLayout, $hFormat, $hBrush)
EndFunc
Func _gdiEnd()
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
EndFunc
Ungetestet!
Es darf nur die _GDIPlus_GraphicsDrawStringEx Funktion in der Schleife stehen, der Rest müsste davor aufgerufen werden.
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.0.0
Author: myName
Script Function:
Template AutoIt script.
#ce ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]; Script Start - Add your code below here
[/autoit] [autoit][/autoit] [autoit]#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>
Global $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout
[/autoit] [autoit][/autoit] [autoit]#cs
fileInstall("C:\Dokumente und Einstellungen\Kev\Desktop\sa\rg_bg\RG_Sig_01.gif",@scriptdir &"\rg_bg\RG_Sig_01.gif")
fileInstall("C:\Dokumente und Einstellungen\Kev\Desktop\sa\rg_bg\RG_Sig_02.gif",@scriptdir &"\rg_bg\RG_Sig_02.gif")
fileInstall("C:\Dokumente und Einstellungen\Kev\Desktop\sa\rg_bg\RG_Sig_03.gif",@scriptdir &"\rg_bg\RG_Sig_03.gif")
fileInstall("C:\Dokumente und Einstellungen\Kev\Desktop\sa\rg_bg\RG_Sig_04.gif",@scriptdir &"\rg_bg\RG_Sig_04.gif")
fileInstall("C:\Dokumente und Einstellungen\Kev\Desktop\sa\rg_bg\RG_Sig_05.gif",@scriptdir &"\rg_bg\RG_Sig_05.gif")
fileInstall("C:\Dokumente und Einstellungen\Kev\Desktop\sa\rg_bg\RG_Sig_06.gif",@scriptdir &"\rg_bg\RG_Sig_06.gif")
fileInstall("C:\Dokumente und Einstellungen\Kev\Desktop\sa\rg_bg\RG_Sig_07.gif",@scriptdir &"\rg_bg\RG_Sig_07.gif")
fileInstall("C:\Dokumente und Einstellungen\Kev\Desktop\sa\rg_bg\RG_Sig_08.gif",@scriptdir &"\rg_bg\RG_Sig_08.gif")
fileInstall("C:\Dokumente und Einstellungen\Kev\Desktop\sa\rg_bg\RG_Sig_09.gif",@scriptdir &"\rg_bg\RG_Sig_09.gif")
fileInstall("C:\Dokumente und Einstellungen\Kev\Desktop\sa\rg_bg\RG_Sig_10.gif",@scriptdir &"\rg_bg\RG_Sig_10.gif")
fileInstall("C:\Dokumente und Einstellungen\Kev\Desktop\sa\rg_bg\RG_Sig_11.gif",@scriptdir &"\rg_bg\RG_Sig_11.gif")
fileInstall("C:\Dokumente und Einstellungen\Kev\Desktop\sa\rg_bg\RG_Sig_12.gif",@scriptdir &"\rg_bg\RG_Sig_12.gif")
#ce
Global $suchen
Global $progress1
Global $fertig
Global $ab
$gui1 = GUICreate("Rising Gods Installer", 500, 299)
GUICtrlCreateLabel("Willkommen bei dem Installations-Assistenten für" & @CRLF & " » Rising Signatur «", 35, 30, 500, 200)
GUICtrlSetFont(-1, 15)
GUICtrlSetState(-2, $GUI_DISABLE)
GUICtrlCreateLabel("Dieser Assistent wird sie durch die Installation von » Rising Signatur « begleiten.", 80, 100, 400, 50)
GUICtrlCreateLabel("Programm by Anubiz - GFX by Feyth", 165, 280, 180, 90)
GUICtrlSetState(-1, $GUI_DISABLE)
$Button1 = GUICtrlCreateButton("Weiter >", 130, 240, 120, 25)
$Button2 = GUICtrlCreateButton("Abbrechen", 255, 240, 120, 25)
$pic = GUICreate("", 68, 71, 5, 50, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $gui1)
GUICtrlCreatePic("..\GUI\merlin.gif", 0, 0, 0, 0)
GUISetState(@SW_SHOW, $pic)
GUISetState(@SW_SHOW, $gui1)
_gdiStart($gui1)
While 1
_gdiText("Test")
$nmsg = GUIGetMsg()
Switch $nmsg
Case $GUI_EVENT_CLOSE
_gdiEnd()
Exit
Case $Button2
_gdiEnd()
Exit
Case $Button1
ExitLoop
EndSwitch
WEnd
_gdiEnd()
$gui2 = GUICreate("Rising Gods Installer Zielverzeichnis", 500, 299)
GUICtrlCreateLabel("Zielverzeichnis auswählen", 35, 30, 500, 200)
GUICtrlSetFont(-1, 15)
GUICtrlSetState(-2, $GUI_DISABLE)
GUICtrlCreateLabel("Rising Signatur wird in das unten angegebene Verzeichnis installiert. Falls Sie in ein anderes Verzeichnis installieren möchten, klicken Sie auf Durchsuchen und wählen Sie ein anderes Verzeichnis aus. Klicken Sie auf Weiter, um fortzufahren", 80, 65, 300, 80)
GUICtrlCreateLabel("Der Ordner für dieses Programm wird extra angelegt.", 40, 140, 400, 50)
GUICtrlCreateLabel("Programm by Anubiz - GFX by Feyth", 165, 280, 180, 90)
GUICtrlSetState(-1, $GUI_DISABLE)
$folder = GUICtrlCreateInput("C:/Programme/", 45, 175, 250, 25)
$suchen = GUICtrlCreateButton("Durchsuchen...", 320, 175, 120, 25)
$install = GUICtrlCreateButton("Installieren", 130, 240, 120, 25)
$Button2 = GUICtrlCreateButton("Abbrechen", 255, 240, 120, 25)
GUIDelete($gui1)
$pic = GUICreate("", 68, 71, 5, 50, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $gui2)
GUICtrlCreatePic("..\GUI\merlin.gif", 0, 0, 0, 0)
GUISetState(@SW_SHOW, $pic)
GUISetState(@SW_SHOW, $gui2)
While 1
$nmsg = GUIGetMsg()
Switch $nmsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button2
Exit
Case $install
$temp = GUICtrlRead($folder)
gui()
copy()
Case $suchen
$input = FileSelectFolder("test", "test")
GUICtrlSetData($folder, $input)
EndSwitch
WEnd
Func gui()
$gui3 = GUICreate("Rising Gods Installer Installation", 500, 299)
GUICtrlCreateLabel("Installation", 35, 30, 500, 200)
GUICtrlSetFont(-1, 15)
GUICtrlSetState(-2, $GUI_DISABLE)
GUICtrlCreateLabel("Installation wird durchgeführt...bitte warten...", 40, 80, 400, 50)
GUICtrlCreateLabel("Dateien werden kopiert...", 40, 115, 400, 50)
$progress1 = GUICtrlCreateProgress(40, 180, 400, 12)
GUICtrlCreateLabel("Programm by Anubiz - GFX by Feyth", 165, 280, 180, 90)
GUICtrlSetState(-1, $GUI_DISABLE)
$fertig = GUICtrlCreateButton("Fertig stellen", 130, 240, 120, 25)
GUICtrlSetState(-1, $GUI_DISABLE)
$ab = GUICtrlCreateButton("Abbrechen", 255, 240, 120, 25)
GUIDelete($gui2)
$pic = GUICreate("", 68, 71, 235, 50, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $gui3)
GUICtrlCreatePic("..\GUI\merlin.gif", 0, 0, 0, 0)
GUISetState(@SW_SHOW, $pic)
GUISetState(@SW_SHOW, $gui3)
EndFunc ;==>gui
Func copy()
DirCreate($temp & "\RisingSignature\rg_bg\")
Sleep(500)
For $i = 1 To 12
If $i < 10 Then
FileCopy(@ScriptDir & "/rg_bg/RG_Sig_0" & $i & ".gif", $temp & "/RisingSignature/rg_bg/RG_Sig_0" & $i & ".gif")
Else
FileCopy(@ScriptDir & "/rg_bg/RG_Sig_" & $i & ".gif", $temp & "/RisingSignature/rg_bg/RG_Sig_" & $i & ".gif")
EndIf
GUICtrlSetData($progress1, ($i * 100) / 12)
Next
MsgBox(0, "Status", "Rising Signatur wurde erfolgreich installiert")
GUICtrlSetState($fertig, $GUI_ENABLE)
While 1
$nmsg = GUIGetMsg()
Switch $nmsg
Case $GUI_EVENT_CLOSE
Exit
Case $fertig
Exit
Case $ab
Exit
EndSwitch
WEnd
EndFunc ;==>copy
[/autoit] [autoit][/autoit] [autoit]Func _gdiStart($hGui)
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI)
$hBrush = _GDIPlus_BrushCreateSolid(0x7F00007F)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
$tLayout = _GDIPlus_RectFCreate(140, 140, 100, 20)
EndFunc
func _gdiText($sText)
_GDIPlus_GraphicsDrawStringEx($hGraphic, $sText, $hFont, $tLayout, $hFormat, $hBrush)
EndFunc
Func _gdiEnd()
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
EndFunc
autoBert: Kanns gerade nicht testen, aber bei dir müsste der Arbeitsspeicherverbrauch linear ansteigen, da du immer wieder neue GDI Objekte initialisierst.
Ich experimentiere gerade etwas mit OpenGL und bin dabei über ein Problem gestolpert.
Die glOrtho zeigt keine Reaktion, ich weiß aber auch nicht wo der Fehler liegen sollte.
Kennt sich jemand damit aus???
#include <GuiConstants.au3>
#include <OpenGL.au3>
#include <Math.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GUIScrollBars.au3>
#include <ScrollBarConstants.au3>
Global $GUI, $DC, $OpenGL
[/autoit] [autoit][/autoit] [autoit]$GUI = GuiCreate("OpenGl", 800, 600, -1, -1 , $WS_SIZEBOX + $WS_SYSMENU + $WS_MINIMIZEBOX + $WS_MAXIMIZEBOX)
$OpenGL = GUICtrlCreateOpenGL($DC, 0, 0, 800, 600)
If @Error Then Exit
GUICtrlSetResizing($OpenGL, $GUI_DOCKBORDERS)
_GUIScrollBars_Init($GUI)
_GUIScrollBars_SetScrollInfoPage($GUI, $SB_VERT, 600)
_GUIScrollBars_SetScrollInfoPage($GUI, $SB_HORZ, 800)
_GUIScrollBars_ShowScrollBar($gui, $SB_BOTH)
$pos = ControlGetPos($GUI, "", $OpenGL)
glViewport(0, 0, $pos[2], $pos[3])
glMatrixMode($GL_PROJECTION)
glLoadIdentity()
glOrtho(0, 9, 0, 9, -1, 1)
glMatrixMode($GL_MODELVIEW)
glLoadIdentity()
glColor3f(0, 0, 1)
glClearColor(1, 1, 1, 1)
GuiSetState()
While 1
$msg = GuiGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
glClear($GL_COLOR_BUFFER_BIT)
[/autoit] [autoit][/autoit] [autoit]glBegin($GL_QUADS)
glVertex2i(0,
glVertex2i(8,
glVertex2i(8, 0)
glVertex2i(0, 0)
glEnd()
SwapBuffers($DC)
WEnd
Func GUICtrlCreateOpenGL(ByRef $hDC, $x, $y, $width, $height)
Local $control = GUICtrlCreateLabel("", $x, $y, $width, $height)
Local Const $PFD_TYPE_RGBA = 0
Local Const $PFD_MAIN_PLANE = 0
Local Const $PFD_DOUBLEBUFFER = 1
Local Const $PFD_DRAW_TO_WINDOW = 4
Local Const $PFD_SUPPORT_OPENGL = 32
Local $pfd = DllStructCreate("short nSize;" & _
"short nVersion;" & _
"dword dwFlags;" & _
"byte iPixelType;" & _
"byte cColorBits;" & _
"byte cRedBits;" & _
"byte cRedShift;" & _
"byte cGreenBits;" & _
"byte cGreenShift;" & _
"byte cBlueBits;" & _
"byte cBlueShift;" & _
"byte cAlphaBits;" & _
"byte cAlphaShift;" & _
"byte cAccumBits;" & _
"byte cAccumRedBits;" & _
"byte cAccumGreenBits;" & _
"byte cAccumBlueBits;" & _
"byte cAccumAlphaBits;" & _
"byte cDepthBits;" & _
"byte cStencilBits;" & _
"byte cAuxBuffers;" & _
"byte iLayerType;" & _
"byte bReserved;" & _
"dword dwLayerMask;" & _
"dword dwVisibleMask;" & _
"dword dwDamageMask;")
Local $h_dc = DllCall("user32.dll", "hwnd", "GetDC", "hwnd", GUICtrlGetHandle($control))
[/autoit] [autoit][/autoit] [autoit]DllStructSetData($pfd, "nSize", DllStructGetSize($pfd))
DllStructSetData($pfd, "nVersion", $GL_VERSION_1_1)
DllStructSetData($pfd, "dwFlags", BitOR($PFD_DRAW_TO_WINDOW, $PFD_SUPPORT_OPENGL, $PFD_DOUBLEBUFFER))
DllStructSetData($pfd, "iPixelType", $PFD_TYPE_RGBA)
DllStructSetData($pfd, "cColorBits", 24)
DllStructSetData($pfd, "cDepthBits", 16)
DllStructSetData($pfd, "iLayerType", $PFD_MAIN_PLANE)
Global $gdi = DllOpen("gdi32.dll")
If @Error Then
SetError(1)
Return 0
EndIf
Global $opengl = DllOpen("opengl32.dll")
If @Error Then
SetError(1)
Return 0
EndIf
Local $iFormat = DllCall($gdi, "int", "ChoosePixelFormat", "hwnd", $h_dc[0], "ptr", DllStructGetPtr($pfd))
Local $iSetFormat = DllCall($gdi, "int", "SetPixelFormat", "hwnd", $h_dc[0], "int", $iFormat[0], "ptr", DllStructGetPtr($pfd))
Local $h_cont = DllCall($opengl, "hwnd", "wglCreateContext", "hwnd", $h_dc[0])
Local $iRet = DllCall($opengl, "int", "wglMakeCurrent", "int", $h_dc[0], "int", $h_cont[0])
$hDC = $h_dc[0]
[/autoit] [autoit][/autoit] [autoit]Return $control
EndFunc ;==>EnableOpenGL
Func SwapBuffers($hDC)
DllCall($gdi, "int", "SwapBuffers", "hwnd", $hDC)
EndFunc ;==>SwapBuffers
Edit: Auf die Nutzung des Plugin würde ich gerne verzichten. Das macht das umschreiben in eine andere Sprache nur kompliziert, falls Autoit zu langsam ist.
Edit2: OK, doofe Frage. glOrtho legt nur den Zeichenbereich fest, Transformiert wird mit glScalef und glTranslatef. Gelöst^^
Für die Makros benötigst du keine UDF, es fehlt nur das Verknüpfungszeichen &.
[autoit]ShellExecute(@Desktopdir & "\MeinProgramm.exe")
[/autoit]Edit: Auf der Startseite links unten findest du einen Link auf die deutsche Hilfe.
Link:
http://translation.autoit.de/autoitinfo/hil…nd-06_02_10.zip
PS: wenn du auf einen Befehl im Forum klickst, erhälst du ebenfalls eine deutsche Hilfe über den Befehl.
Du versuchst die Gui mit _GDIPlus_GraphicsDispose() zu killen, probiers mal so:
#include <GDIPlus.au3>
#include <GUIConstants.au3>
Global $gui = GUICreate("GDI+",500,500,-1,-1)
GUISetState(@SW_SHOW)
_GDIPlus_Startup()
$gdi_hwnd = _GDIPlus_GraphicsCreateFromHWND($gui)
$pen = _GDIPlus_PenCreate(0xFF000000,5)
_GDIPlus_GraphicsDrawEllipse($gdi_hwnd,100,100,100,100,$pen)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
_GDIPlus_GraphicsDispose($gdi_hwnd) ;### Änderung ###
_GDIPlus_PenDispose($pen)
_GDIPlus_Shutdown()
Exit
EndSwitch
WEnd
edit: zu langsam
Da gibt es eine Windows Media Player UDF:
[ offen ] Internetradio empfangen
Versteh immernoch nicht warum man was ersetzen soll? Hier mal mein Ansatz:
(Die abgeänderte Funktion von Thorsten Willert)
#include <Array.au3>
$hFile = @ScriptDir & "\Test.csv"
$split = _CSV2Array($hFile, ",", False)
If @error then MsgBox(0, @error, "")
_ArrayDisplay($split)
; #FUNCTION# ===================================================================
; Name ..........: _CSV2Array
; Description ...:
; AutoIt Version : V3.3.0.0
; Syntax ........: _CSV2Array($hFile[, $cSeperator = "auto"[, $bFilterString = True[, $iColumnMode = 0]]])
; Parameter(s): .: $hFile - Handle for the CSV file to Read
; $cSeperator - Optional: (Default = "auto") : Tries to find the separator char or , or TAB or | or space)
; | Data-seperator-char
; | Empty-string = Opt("GUIDataSeparatorChar")
; $bFilterString - Optional: (Default = True) : Removes leading and trailing " or '
; $iColumnMode - Optional: (Default = 0) :
; | 0: Sets error if lines have different columns and @extended to the csv-line number
; | 1: returns lines with different columns numbers comparing to the first line, too
; | 2: removing all columns > column numbers in the first line
; Return Value ..: Success - 2-dim Array
; Failure - 0
; @ERROR - 1: error file read
; @ERROR - 2: different number of columns / @EXTENDED = CSV-line
; - 3: parameter error
; Author(s) .....: Thorsten Willert
; Date ..........: Mon Dec 07 18:59:46 CET 2009
; ==============================================================================
Func _CSV2Array($hFile, $cSeperator = "auto", $bFilterString = True, $iColumnMode = 0)
Local $s = FileRead($hFile)
If @error Then Return SetError(1)
If $cSeperator = Default Then $cSeperator = "auto"
If Not $cSeperator Then $cSeperator = Opt("GUIDataSeparatorChar")
; searching the line-seperator and splitting the lines into an array
Local $aLines
If StringInStr($s, @CRLF) Then
$aLines = StringSplit($s, @CRLF, 1)
ElseIf StringInStr($s, @CR) Then
$aLines = StringSplit($s, @CR)
Else
$aLines = StringSplit($s, @LF)
EndIf
; searching the delimiter in the first line
Local $aTMP
If $cSeperator = "auto" Then
Local $iMax = 0
Local $iC[5] = [0, 0, 0, 0, 0]
Local $sC[5] = [";", ",", @TAB, "|", " "]
$aTMP = StringRegExp($aLines[1], ";", 3)
If Not @error Then $iC[0] = UBound($aTMP)
$aTMP = StringRegExp($aLines[1], ",", 3)
If Not @error Then $iC[1] = UBound($aTMP)
$aTMP = StringRegExp($aLines[1], "\t", 3)
If Not @error Then $iC[2] = UBound($aTMP)
$aTMP = StringRegExp($aLines[1], "\|", 3)
If Not @error Then $iC[3] = UBound($aTMP)
$aTMP = StringRegExp($aLines[1], "[ ]", 3)
If Not @error Then $iC[4] = UBound($aTMP)
For $i = 0 To UBound($sC) - 1
If $iC[$i] > $iMax Then
$iMax = $iC[$i]
$cSeperator = $sC[$i]
EndIf
Next
EndIf
; creating 2-dim array based on the number of data in the first line
$aTMP = StringRegExp($aLines[1], '((?:")(?:.*?)(?:")|(?:.+?))(?:' & $cSeperator & '|$)' , 3)
Local $iCol = Ubound($aTMP)
Local $aRet[$aLines[0]][$iCol]
; splitting and filling the lines
For $i = 1 To $aLines[0]
$aTMP = StringRegExp($aLines[$i], '((?:")(?:.*?)(?:")|(?:.+?))(?:' & $cSeperator & '|$)' , 3)
If @error Then ContinueLoop
If $aTMP[0] > $iCol Then
Switch $iColumnMode
Case 0
Return SetError(2, $i)
Case 1
ReDim $aRet[$aLines[0] - 1][$aTMP[0]]
Case 2
$aTMP[0] = $iCol
Case Else
Return SetError(3)
EndSwitch
EndIf
For $j = 0 To Ubound($aTMP) - 1
$aTMP[$j] = StringStripWS($aTMP[$j], 3)
; removing leading and trailing " or '
If $bFilterString Then $aTMP[$j] = StringRegExpReplace($aTMP[$j], '^("|'')(.*?)\1$', '$2')
$aRet[$i - 1][$j] = $aTMP[$j]
Next ; /cols
Next ; /lines
Return $aRet
EndFunc ;==>_CSV2Array
Wenn ich deine Erklärung richtig verstanden habe, sollte folgender StringRegExp helfen:
[autoit]
$string = '"Test, GmbH Test",Musterstraße 1,01234 Musterhausen'
$split = StringRegExp($string, '((?:")(?:.+?)(?:")|(?:.+?))(?:,|$)' , 3)
MsgBox(0, "Treffer:", $split[0] & ";" & $split[1] & ";" & $split[2])
Es wird an jedemKomma gesplittet, das nicht innerhalb von Anführungszeichen "" liegt.
Dann mach das Flashcontrol doch kleiner, so das es sich nicht mehr überlappt.
#include <GUIConstantsEx.au3>
GUICreate("Test", 600, 400)
$Flash = ObjCreate("ShockwaveFlash.ShockwaveFlash")
$FlashObj = GUICtrlCreateObj($Flash, 350, 0, 250, 490)
$Flash.Movie = "C:\loader.swf?mainfile=C:\main.swf"
$Flash.loop = true
GUISetState(@SW_SHOW)
$pic = GUICtrlCreatePic("C:\image1.bmp",0,-5,350,450,0)
GUICtrlSetSTate($pic,$GUI_DISABLE)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Bei mir gehts, hoff mal das es unter anderen Flashversionen auch zentriert dargestellt wird.
Lag wahrscheinlich wirklich an der zu langen Adlib Funktion.
Hier die geänderte Variante, bitte mal testen.
Danke an alle
#include "_TocLib.au3"
#include <Timers.au3>
#include <GUIConstants.au3>
OnAutoItExitRegister("_Exit")
[/autoit] [autoit][/autoit] [autoit]Global $User = "123456789"
Global $Pass = "passwort"
$hWnd = GUICreate("ICQ - Ersatz", 280, 300)
$hUser = GUICtrlCreateInput($User, 10, 10, 80, 20)
$hPass = GUICtrlCreateInput($Pass, 100, 10, 80, 20)
$hLogin = GUICtrlCreateButton("Login", 190, 10, 80, 20)
$hList = GUICtrlCreateListView("Nummer|Nickname", 140, 40, 130, 250)
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
Case $hLogin
Login()
EndSwitch
$msg = _TOCGetMsg()
If $msg == $TOC_CMD_IMRECV Then
$msg = _TocParseIm()
If (_Timer_GetIdleTime() > 2000 * 60) Then ;Ist man länger als 2 Minuten abwesend, wird diese Nachricht gesendet:
_TocSendIM($msg[0], "Bin gerade nicht am PC, versuche es bitte später nochmal.", True)
_TocSetAway("PC nicht besetzt!")
EndIf
EndIf
If $msg == $TOC_CMD_CONFIG Then
$msg = _TocParseConfig()
For $i = 0 To UBound($msg) - 1
GUICtrlCreateListViewItem($msg[$i], $hList)
Next
EndIf
_TOCClearMsg()
WEnd
Func Login()
$login = _TocLogin(GUICtrlRead($hUser), GUICtrlRead($hPass))
If Not $login Then
If @error == $TOC_ERROR Then
_DebugPrint("TOC Error: code " & $login)
Else
_DebugPrint("_TocLogin @error = " & @error)
EndIf
Else
_DebugPrint("Logged in successfully")
GUICtrlSetState($hLogin, $GUI_DISABLE)
_TocInitLoop()
EndIf
EndFunc ;==>Login
Func _Exit()
_TocCleanup()
EndFunc ;==>_Exit
_TocLib:
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.2.1.12 (beta)
Script Version: 2.1.1.0
Author: Daniel "Falcone88" Leong
Script Function:
My own UDF for the TOC (Talk To Oscar) Protocol
Documentation for the protocol itself may be found in the following:
http://terraim.cvs.sourceforge.net/*checkout*/ter…rc/toc/TOC1.txt
http://terraim.cvs.sourceforge.net/*checkout*/ter…rc/toc/TOC2.txt
The following, though a bit dated, was still very helpful:
http://www2.sys-con.com/ITSG/virtualcd…aton/index.html
If something isn't in the TOC2 docs, it is the same asin TOC1. Note, of course,
that the most recent things (IE: as shown in TOC2) must be used.
List of functions:
_TocLogin
_TocFinalizeLogin
_TocSendIM
_TocSetAway
_TocParseIm
_TocParseConfig <- doesn't do anything yet
_TocCleanup
_TocRegisterFunc
_TocIsRegistered
_TocInitLoop
_TocStopLoop
_TocDoLoop
_TocRoastPass
_TocNormalizeName
_TocNormalizeString
_TocMakeSigninCode
_TocMakeFlapPacket
_TocDecodeFlap
_TocSendFlap
_TocSendRaw
_TocWaitFlap
_TocGetFlap
_BinaryNumber
_BinaryNumberDecode
#ce ----------------------------------------------------------------------------
#include <Array.au3>
[/autoit] [autoit][/autoit] [autoit]; @error codes
Global Const $TOC_TCP_FAIL = 1 ; could not init TCP
Global Const $TOC_CONNECT_FAIL = 2 ; could not connect to toc server
Global Const $TOC_SEND_FAIL = 3 ; could not send over TCP for some reason
Global Const $TOC_ERROR = 4 ; TOC server sent an error code
Global Const $TOC_NO_HANDLERS = 5 ; no functions to handle inputs defined
Global Const $TOC_CMD_TOOLONG = 6 ; attempted to send a string to TOC longer than max
; TOC errors
#cs
* General Errors *
901 - $1 not currently available
902 - Warning of $1 not currently available
903 - A message has been dropped, you are exceeding
the server speed limit
;* Admin Errors *
911 - Error validating input
912 - Invalid account
913 - Error encountered while processing request
914 - Service unavailable
* Chat Errors *
950 - Chat in $1 is unavailable.
* IM & Info Errors *
960 - You are sending message too fast to $1
961 - You missed an im from $1 because it was too big.
962 - You missed an im from $1 because it was sent too fast.
* Dir Errors *
970 - Failure
971 - Too many matches
972 - Need more qualifiers
973 - Dir service temporarily unavailable
974 - Email lookup restricted
975 - Keyword Ignored
976 - No Keywords
977 - Language not supported
-Update: 977 can also mean no directory information available
978 - Country not supported
979 - Failure unknown $1
* Auth errors *
980 - Incorrect nickname or password.
981 - The service is temporarily unavailable.
982 - Your warning level is currently too high to sign on.
983 - You have been connecting and
disconnecting too frequently. Wait 10 minutes and try again.
If you continue to try, you will need to wait even longer.
989 - An unknown signon error has occurred $1
#ce
; TOC Server -> Client commands
Global Const $TOC_CMD_SIGNON = "SIGN_ON"
Global Const $TOC_CMD_IMRECV = "IM_IN_ENC2"
Global Const $TOC_CMD_CONFIG = "CONFIG2"
Global Const $TOC_CMD_BUDDY_ACCEPTED = "NEW_BUDDY_REPLY2"
Global Const $TOC_CMD_CHATRECV = "CHAT_IN_ENC"
Global Const $TOC_CMD_BUDDY_UPDATE = "UPDATE_BUDDY2"
Global Const $TOC_CMD_CHAT_UPDATE = "CHAT_UPDATE_BUDDY"
Global Const $TOC_CMD_CHATINVITE = "CHAT_INVITE"
Global Const $TOC_CMD_ERROR = "ERROR"
Global Const $TOC_CMD_ANY = "~ANY~" ; catches anything not registered otherwise
; FLAP constant crap
$TOC_FLAP_ON = "FLAPON" & @CRLF & @CRLF
$TOC_ROAST_STRING = "Tic/Toc"
$TOC_LANGUAGE = "english"
$TOC_VERSION = "TIC:TOCLib for Autoit by Dan Leong"
$TOC_COUNTRY = "US"
$TOC_MAX_CHAR_LENGTH = 2048
$TOC_MAX_CHAR_RECV = 8192
$TOC_SIGNON_TYPE = 1
$TOC_DATA_TYPE = 2
; global vars
Global $currSequence = 0
Global $tocTcpSocket
Global $tocVersion = ""
Global $handleRecvCmd[1]
Global $handleRecvFunc[1] ; func called on recieved new message
Global $recvCmdBuffer[1] ; in case we recieve messages too fast, we'll throw extra ones into a buffer
Global $recvMsgBuffer[1]
;===============================================================================
;
; Description: Login to the TOC Server
; Parameter(s): $sUser - Username for AIM
; $sPass - Password for AIM
; $fFinalize - Whether or not to finalize connection (see notes)
; $sTocServer - TOC Servername. The default should be fine, but
; localhost may be used for testing...
; $iTocPort - TOC port to connect to. Again, default should be fine
; $sAuthServer - Authentication server. (Allows you to login to AIM)
; $iAuthPort - Port of the Auth Server
; Requirement(s): None
; Return Value(s): On Success - true
; On Failure - false and Set
; @ERROR to: $TOC_CONNECT_FAIL - Could not connect to TOC server
; $TOC_SEND_FAIL - Could not send data to the server
; $TOC_ERROR - Recieved an ERROR message from the TOC server
; The error number will be set in @extended
; Author(s): Dan "Falcone88" Leong
; Note(s): If you want to send configurations to the TOC server (say, you're making an AIM client),
; you will want to set this to false, send your config, then use _TocFinalizeLogin(). Note
; that this must be sent within 30 seconds of _TocLogin()'s return, or the server will drop
; the connection.
;
; The comments on the format of the packets were taken from one of the websites at the top
; of this file.
;
;===============================================================================
Func _TocLogin($sUser, $sPass, $fFinalize = True, $sTocServer = "toc.oscar.aol.com", $iTocPort = 9898, $sAuthServer = "login.oscar.aol.com", $iAuthPort = 5190)
If Not TCPStartup() Then
SetError($TOC_TCP_FAIL)
Return False
EndIf
$tocTcpSocket = TCPConnect(TCPNameToIP($sTocServer), $iTocPort)
[/autoit] [autoit][/autoit] [autoit]If $tocTcpSocket == -1 Then
SetError($TOC_CONNECT_FAIL)
Return False
EndIf
; initialize FLAP
$bytes = _TocSendRaw($TOC_FLAP_ON)
If $bytes == 0 Then
SetError($TOC_SEND_FAIL)
Return False
EndIf
_DebugPrint("Sent FLAPON")
; wait for TOC version
$tocVersion = _TocWaitFlap()
_DebugPrint("Recieved TOC Version")
; send "signon" packet
#cs
First, the version numbers, then a word of 0x0001. This indicates that a user name will follow.
The next word represents the length of the screen name. Following the length is the normalized
representation of the screen name - all spaces are removed and the entire name is converted to lowercase.
#ce
$bytes = _TocSendFlap($tocVersion & BinaryString("0x0001") & ( _BinaryNumber(StringLen($sUser))) & _TocNormalizeName($sUser), $TOC_SIGNON_TYPE)
If $bytes == 0 Then
SetError($TOC_SEND_FAIL)
Return False
EndIf
_DebugPrint("Sent SIGNON")
; login
#cs
toc2_login <address> <port> <screenname> <roasted pw> <language> <version*> 160 US "" "" 3 0 30303 -kentucky -utf8 76144224***
* The version string MUST start with "TIC:" otherwise, no dice. For example, "TIC:AIMM" is ok, but "AIMM2" would be rejected.
** I have no idea what the parameters after the version are. Put them in verbatim and logging in works.
*** See _TocMakeSigninCode()
#ce
$loginStr = 'toc2_login ' & $sAuthServer & ' ' & $iAuthPort & ' "' & $sUser & '" ' & _TocRoastPass($sPass) & ' "'
$loginStr &= $TOC_LANGUAGE & '" "' & $TOC_VERSION & '" 160 ' & $TOC_COUNTRY & ' "" "" 3 0 30303 -kentucky -utf8 '
$loginStr &= _TocMakeSigninCode($sUser, ($sPass))
$bytes = _TocSendFlap($loginStr)
If $bytes == 0 Then
SetError($TOC_SEND_FAIL)
Return False
EndIf
_DebugPrint("Sent LOGIN")
$response = _TocWaitFlap(2)
_DebugPrint(_ArrayToString($response, " "))
If $response[1] = $TOC_CMD_ERROR Then
SetError($TOC_ERROR, StringLeft($response[2], 3), False)
ElseIf $response[1] = $TOC_CMD_SIGNON Then
_DebugPrint("Logged on successfully")
If $fFinalize Then _TocFinalizeLogin()
[/autoit] [autoit][/autoit] [autoit]Return True
Else
_DebugPrint("Weird.. I see (" & $response[1] & ")")
SetError($TOC_ERROR)
Return False
EndIf
Return False ; just in case
EndFunc ;==>_TocLogin
;===============================================================================
;
; Description: Finalize login to AIM server
; Parameter(s): None
; Requirement(s): A successful call to _TocLogin()
; Return Value(s): Number of bytes sent via TCP
;
; Author(s): Dan "Falcone88" Leong
; Note(s): See _TocLogin()
;
;===============================================================================
Func _TocFinalizeLogin()
Return _TocSendFlap("toc_init_done")
EndFunc ;==>_TocFinalizeLogin
;===============================================================================
;
; Description: Send an IM to specified user via AIM
; Parameter(s): $sUser - Target user's AIM screenname
; $sMsg - The message to send
; $fAuto - Whether or not to specify the message as an auto response
; Requirement(s): A successful call to _TocLogin()
; Return Value(s): Number of bytes sent via TCP
;
; Author(s): Dan "Falcone88" Leong
; Note(s): None.
;
;===============================================================================
Func _TocSendIM($sUser, $sMsg, $fAuto = False)
Local $packet = 'toc2_send_im ' & _TocNormalizeName($sUser) & ' "'
$packet &= _TocNormalizeString($sMsg) & '"'
[/autoit] [autoit][/autoit] [autoit]If $fAuto Then $packet &= ' auto'
Return _TocSendFlap($packet)
EndFunc ;==>_TocSendIM
;===============================================================================
;
; Description: Set your away message
; Parameter(s): $sMsg - The away message to set
;
; Requirement(s): A successful call to _TocLogin()
; Return Value(s): Number of bytes sent via TCP
;
; Author(s): Dan "Falcone88" Leong
; Note(s): If you call without any arguments, it will set status to
; available.
;
;===============================================================================
Func _TocSetAway($sMsg = "")
Return _TocSendFlap('toc_set_away "' & _TocNormalizeString($sMsg) & '"')
EndFunc ;==>_TocSetAway
;===============================================================================
;
; Description: Parse in IM_IN packet from TOC2 into something useful
; Parameter(s): $sPacket - The packet data from IM_IN (Just the data part, not FLAP)
; Requirement(s): Array.au3
; Return Value(s): On Success - An array as follows:
; $ret[0] = username from
; $ret[1] = auto or not (String "T"/"F")
; $ret[2] = buddy status
; $ret[3] = message
; On Failure - "" and Set @ERROR to 1
; Author(s): Dan "Falcone88" Leong
; Note(s): $sPacket SHOULD look like this: (I think)
; <user>:<auto>:<???>:<???>:<buddy status>:<???>:<???>:en:<message>
; Note the omission of IM_IN_ENC2... That's because it's omitted in
; the way _TocDoLoop() calls registered functions
; Alternatively, it can be an array as returned by _TocGetFlap(2)
;
;===============================================================================
Func _TocParseIm()
Local $ret[4]
Local $sPacket = StringSplit($recvMsgBuffer[1], ":")
If @error Then
SetError(1)
Return 0
EndIf
_ArrayDelete($recvMsgBuffer, 1)
$recvMsgBuffer[0] -= 1
$ret[0] = $sPacket[1]
$ret[1] = $sPacket[2]
$ret[2] = $sPacket[5]
$ret[3] = _ArrayToString($sPacket, ":", 9)
Return $ret
EndFunc ;==>_TocParseIm
;===============================================================================
;
; Description: Parse a CONFIG2 packet from TOC2 into something useful
; Parameter(s): $sPacket - The packet data from CONFIG2 (Just the data part, not FLAP)
; Requirement(s): none
; Return Value(s): On Success - An array as follows:
; $ret[0] = 1. Usernumber | Username
; $ret[1] = 2. Usernumber | Username
; $ret[2] = 3. Usernumber | Username
; ...
; Author(s): Dan "Falcone88" Leong
; Note(s): Obviously, this does nothing at the moment. Looking at samples,
; It so far seems pointless to include this, as there's no really
; good way that I can see implementing this as a helpful function
; without using some strange 3d array
;
;===============================================================================
Func _TocParseConfig()
Local $aUsers, $i, $reg, $ret[1]
$aUsers = StringRegExp($recvMsgBuffer[1], "b:(.*?)" & @LF, 3)
If @error Then
SetError(1)
Return 0
EndIf
_ArrayDelete($recvMsgBuffer, 1)
$recvMsgBuffer[0] -= 1
;~ ConsoleWrite("-" & $aUsers[0] & @CRLF)
Local $size = UBound($aUsers)
ReDim $ret[$size]
For $i = 0 To UBound($aUsers) - 1
$reg = StringRegExp($aUsers[$i] & @LF, "(.*?):(.*?)(?::*)" & @LF, 3)
$ret[$i] = $reg[0] & "|" & BinaryToString(StringToBinary($reg[1], 1), 4) ; User Number & "|" & User Name (UTF8 -> ASCII)
Next
Return $ret
EndFunc ;==>_TocParseConfig
;===============================================================================
;
; Description: Cleanup the TCP connections and such
; Parameter(s): None
; Requirement(s): None
; Return Value(s): None
;
; Author(s): Dan "Falcone88" Leong
; Note(s): None
;
;===============================================================================
Func _TocCleanup()
_TocStopLoop()
TCPCloseSocket($tocTcpSocket)
TCPShutdown()
EndFunc ;==>_TocCleanup
;
; _TocDoLoop() related functions
;
;===============================================================================
;
; Description: Register a function to be called upon receiving a given command
; Parameter(s): $sCmd - The TOC command to trigger the function
; $sFuncName - Name of the user's function to be called upon recieve
; Requirement(s): Array.au3
; Return Value(s): Always returns true...
; Author(s): Dan "Falcone88" Leong
; Note(s): The function to be called should expect a single argument,
; which will be the exact string arguments provided in the FLAP packet.
;
;===============================================================================
Func _TocRegisterFunc($sCmd, $sFuncName)
$key = _ArraySearch($handleRecvCmd, $sCmd)
If $key == -1 Then
_ArrayAdd($handleRecvCmd, $sCmd)
_ArrayAdd($handleRecvFunc, $sFuncName)
$handleRecvCmd[0] += 1
$handleRecvFunc[0] += 1
Else
$handleRecvFunc[$key] = $sFuncName
EndIf
Return True
EndFunc ;==>_TocRegisterFunc
;===============================================================================
;
; Description: Check if a particular cmd has a function registered with it
; Parameter(s): $sCmd - The TOC command to trigger the function
; $fReturnIndex - whether to return the index of the cmd (if found)
; instead of a boolean
; Requirement(s): Array.au3
; Return Value(s): On Success - if $fReturnIndex=false, returns TRUE
; if $fReturnIndex=true, returns the index of the func
; On Failure - FALSE
;
; Author(s): Dan "Falcone88" Leong
; Note(s): $fReturnIndex=true is probably not necessary for the casual
; user. I use it as a utility for other functions, though
;
;===============================================================================
Func _TocIsRegistered($sCmd, $fReturnIndex = False)
$key = _ArraySearch($handleRecvCmd, $sCmd)
If $key == -1 Then
Return False
Else
If $fReturnIndex Then
Return $key
Else
Return True
EndIf
EndIf
EndFunc ;==>_TocIsRegistered
;===============================================================================
;
; Description: Initialize the AdLib loop that checks for server input and calls
; the appropriate registered functions.
; Parameter(s): $iDelay - Time in ms between function calls (See definition of AdlibEnable)
; Requirement(s): At least one call to _TocRegisterFunc
; Return Value(s): On Success - true
; On Failure - false and Set @ERROR to $TOC_NO_HANDLERS (No functions registered)
; Author(s): Dan "Falcone88" Leong
; Note(s): none
;
;===============================================================================
Func _TocInitLoop($iDelay = 250)
;~ If $handleRecvCmd[0] < 1 Then
;~ SetError($TOC_NO_HANDLERS)
;~ Return False
;~ EndIf
AdlibRegister("_TocDoLoop", $iDelay)
Return True
EndFunc ;==>_TocInitLoop
;===============================================================================
;
; Description: Stop the AdLib loop. That's about it
; Parameter(s): none
; Requirement(s): A previous call to _TocInitLoop()... if you want it to do something
; Return Value(s): none
; Author(s): Dan "Falcone88" Leong
; Note(s): none
;
;===============================================================================
Func _TocStopLoop()
AdlibUnRegister()
EndFunc ;==>_TocStopLoop
;===============================================================================
;
; Description: The function called in each loop to parse packets.
; Parameter(s): $iDelay - Time in ms between function calls (See definition of AdlibEnable)
; Requirement(s): Array.au3
; Return Value(s): none
; Author(s): Dan "Falcone88" Leong
; Note(s): When it finds a handled command, it sends the whole
; argument string to that function. The command itself is,
; of course, omitted, as you should know what command it's handling.
;
;===============================================================================
Func _TocDoLoop()
Local $packet = TCPRecv($tocTcpSocket, $TOC_MAX_CHAR_RECV)
;~ ConsoleWrite($packet & @CRLF)
If $recvCmdBuffer[0] > 0 Then
$packet = $recvCmdBuffer[1] & $packet
_ArrayDelete($recvCmdBuffer, 1)
$recvCmdBuffer[0] -= 1
EndIf
$decoded = _TocDecodeFlap($packet)
;~ If $decoded <> -1 Then ConsoleWrite($decoded[4] & @CRLF)
; first, see if we got the whole packet
If IsArray($decoded) Then
If $decoded[3] <> StringLen($decoded[4]) Then
; if not, enqueue it
_ArrayAdd($recvCmdBuffer, $packet)
$recvCmdBuffer[0] += 1
; call ourself again to get the rest of the packet
Else
_ArrayAdd($recvMsgBuffer, $decoded[4])
$recvMsgBuffer[0] += 1
ConsoleWrite("!" & $recvMsgBuffer[1] & @CRLF)
If StringLen($decoded[5]) Then
_ArrayAdd($recvCmdBuffer, $decoded[5])
$recvCmdBuffer[0] += 1
EndIf
EndIf
EndIf
EndFunc ;==>_TocDoLoop
Func _TOCGetMsg()
If $recvMsgBuffer[0] > 0 Then
Local $ret = StringSplit($recvMsgBuffer[1], ":")
ConsoleWrite($ret[1] & @CRLF)
Return $ret[1]
EndIf
Return ""
EndFunc ;==>_TOCGetMsg
Func _TOCClearMsg()
If $recvMsgBuffer[0] > 0 Then
_ArrayDelete($recvMsgBuffer, 1)
$recvMsgBuffer[0] -= 1
Return 1
EndIf
Return 0
EndFunc ;==>_TOCClearMsg
;
; Util Funcs
;
;===============================================================================
;
; Description: "Roast" a password. Basically it's a really simple encryption
; that TOC requires
; Parameter(s): $sOldPass - The unencrypted password
; Requirement(s): none
; Return Value(s): The "roasted" password
; Author(s): Dan "Falcone88" Leong
; Note(s): none
;
;===============================================================================
Func _TocRoastPass($sOldPass)
Local $roasted = "0x", $xor_i = 1
For $i = 1 To StringLen($sOldPass)
$roasted &= Hex(BitXOR(Asc(StringMid($TOC_ROAST_STRING, $xor_i, 1)), Asc(StringMid($sOldPass, $i, 1))), 2)
$xor_i += 1
If ($xor_i > StringLen($TOC_ROAST_STRING)) Then $xor_i = 1
Next
Return $roasted
EndFunc ;==>_TocRoastPass
;===============================================================================
;
; Description: "Normalize" a name
; Parameter(s): $sString - The string to "normalize"
; Requirement(s): none
; Return Value(s): The "normalized" name
; Author(s): Dan "Falcone88" Leong
; Note(s): As you can see, this just removes spaces and puts it in lower
; case. This is mostly used for usernames when communicating
; with TOC
;
;===============================================================================
Func _TocNormalizeName($sString)
Return StringReplace(StringLower($sString), " ", "")
EndFunc ;==>_TocNormalizeName
;===============================================================================
;
; Description: "Normalize" a string.
; Parameter(s): $sString - The string to "normalize"
; Requirement(s): none
; Return Value(s): The "normalized" string
; Author(s): Dan "Falcone88" Leong
; Note(s): This changes some characters to something more acceptable to
; TOC. This is another function that received help from
; BlueTOC
;
;===============================================================================
Func _TocNormalizeString($sString)
$sString = StringReplace($sString, "\", "\\")
$sString = StringReplace($sString, "$", "\$")
$sString = StringReplace($sString, '"', '\"')
$sString = StringReplace($sString, "(", "\(")
$sString = StringReplace($sString, ")", "\)")
$sString = StringReplace($sString, "[", "\[")
$sString = StringReplace($sString, "]", "\]")
$sString = StringReplace($sString, "{", "\{")
$sString = StringReplace($sString, "}", "\}")
Return $sString
EndFunc ;==>_TocNormalizeString
;===============================================================================
;
; Description: Create the wierd authentication code needed to login with TOC2
; Parameter(s): $sUser - the username being used to log in
; $sPass - the password
; Requirement(s): none
; Return Value(s): The code
; Author(s): Ahnugslos (optimized)
; Note(s): Original by Dan "Falcone88" Leong
;
;===============================================================================
Func _TocMakeSigninCode($sUser, $sPass)
Return 7696 * Asc(StringLeft($sUser, 1)) * Asc(StringLeft($sPass, 1))
EndFunc ;==>_TocMakeSigninCode
;===============================================================================
;
; Description: Take a TOC command and prepend a FLAP header to it
; Parameter(s): $iType - The type of packet. Can be:
; $TOC_SIGNON_TYPE - used for the signon packet... rarely used
; $TOC_DATA_TYPE - used for nearly everything. Default
; $sData - the command string
; Requirement(s): none
; Return Value(s): The created packet
; Author(s): Dan "Falcone88" Leong
; Note(s): This took me FOREVER to figure out. The most annoying
; part of this whole library, easily
;
;===============================================================================
Func _TocMakeFlapPacket($iType, $sData)
$currSequence += 1
If $iType == $TOC_DATA_TYPE Then $sData &= Chr(0)
$btype = _BinaryNumber($iType, 1)
$bseq = _BinaryNumber(($currSequence))
$blen = _BinaryNumber(StringLen($sData))
$header = "*" & $btype & $bseq & $blen
[/autoit] [autoit][/autoit] [autoit]Return $header & $sData
EndFunc ;==>_TocMakeFlapPacket
;===============================================================================
;
; Description: Decode a raw FLAP packet
; Parameter(s): $bPacket - The packet
;
; Requirement(s): none
; Return Value(s): Success - An array formated as follows:
; $ret[0] = "*"
; $ret[1] = type
; $ret[2] = sequence number
; $ret[3] = length of the packet
; $ret[4] = the packet itself
; $ret[5] = any excess stuff after reading $ret[3] characters
; Failure - The original packet, and sets @ERROR = 1
; Author(s): Dan "Falcone88" Leong
; Note(s): This removes any Chr(0) found in the strings. The fifth index
; is included because sometimes packets are sent quickly and
; become mixed up. This helps to ensure that all packets
; are recieved properly.
;
;===============================================================================
Func _TocDecodeFlap($bPacket)
If BinaryLen($bPacket) < 1 Or Binary(BinaryMid($bPacket, 1, 1)) <> Binary("*") Then
SetError(1) ; not a proper flap packet, returns -1
Return -1
EndIf
Local $ret[6]
[/autoit] [autoit][/autoit] [autoit]$ret[0] = "*"
$ret[1] = _BinaryNumberDecode(BinaryMid($bPacket, 2, 1))
$ret[2] = _BinaryNumberDecode(BinaryMid($bPacket, 3, 2))
$ret[3] = _BinaryNumberDecode(BinaryMid($bPacket, 5, 2))
$ret[4] = StringMid(BinaryToString($bPacket), 7, $ret[3])
$ret[5] = StringMid(BinaryToString($bPacket), 7 + $ret[3])
Return $ret
EndFunc ;==>_TocDecodeFlap
;===============================================================================
;
; Description: Send a packet to TOC with a FLAP header.
; Parameter(s): $sData - The data string to send
; $iType - type of packet (See _TocMakeFlapPacket)
; $fTruncate - See _TocSendRaw()
;
; Requirement(s): none
; Return Value(s): Number of bytes sent via TCP
; Author(s): Dan "Falcone88" Leong
; Note(s): $iType is second so it can be optional and default to $TOC_DATA_TYPE,
; as that is the most common type
;
;===============================================================================
Func _TocSendFlap($sData, $iType = 2, $fTruncate = False)
_DebugPrint("SENT: " & $sData)
Return _TocSendRaw( _TocMakeFlapPacket($iType, $sData))
EndFunc ;==>_TocSendFlap
;===============================================================================
;
; Description: Send a raw packet to TOC server
; Parameter(s): $bData - The data string to send
; $fTruncate - Silently clip $bData if it's too long or not
;
; Requirement(s): Previous successful call to _TocLogin()
; Return Value(s): Success - Number of bytes sent via TCP
; Failure - 0, and set @ERROR = $TOC_CMD_TOOLONG
; Author(s): Dan "Falcone88" Leong
; Note(s): Failure condition only ever occurs if $fTruncate = false. If
; $fTruncate = true, this will not issue any errors even if
; the string is longer than allowed ($TOC_MAX_CHAR_LENGTH). It
; will simply truncate the string to the allowed length
;
;===============================================================================
Func _TocSendRaw($bData, $fTruncate = False)
If Not $fTruncate And StringLen($bData) > $TOC_MAX_CHAR_LENGTH Then
SetError($TOC_CMD_TOOLONG)
Return 0
EndIf
Return TCPSend($tocTcpSocket, StringLeft($bData, $TOC_MAX_CHAR_LENGTH))
EndFunc ;==>_TocSendRaw
;===============================================================================
;
; Description: Wait until a packet is recieved from the TOC server
; Parameter(s): $iRetType - Return format; See _TocGetFlap
;
; Requirement(s): Previous successful call to _TocLogin()
; Return Value(s): See _TocGetFlap
; Author(s): Dan "Falcone88" Leong
; Note(s): none
;
;===============================================================================
Func _TocWaitFlap($iRetType = 1)
Local $packet = ""
Do
$packet = _TocGetFlap($iRetType)
Until $packet <> -1
[/autoit] [autoit][/autoit] [autoit]Return $packet
EndFunc ;==>_TocWaitFlap
;===============================================================================
;
; Description: Instantaneous (non-blocking) check for a flap packet
; Parameter(s): $iRetType - Format for the return value
;
; Requirement(s): Previous successful call to _TocLogin()
; Return Value(s): Success - Returns the packet, depending on $iRetType:
; 0 - Full packet, raw (including FLAP header)
; 1 - The data part (everything BUT header), raw
; 2 - The data part (everything BUT header), split into
; an array using ":" as the delimeter
; Failure - (No new packet) returns -1
; Author(s): Dan "Falcone88" Leong
; Note(s): This function looks about 25 lines longer than it needs to be,
; but that's because it takes into account packets sent in
; really close proximity that consequently might be interpretted as a single packet.
; Extra packets are added to $recvCmdBuffer and are inserted before the next recieved
; packet in order recieved. (Obviously, there could be a backup if a packet wasn't split up,
; which this method accounts for. However, this is not a problem, as the new packet will
; be found and added to the end of the buffer.
;
;===============================================================================
Func _TocGetFlap($iRetType = 0, $fCalledFromLoop = False)
Local $decoded, $extraString, $newPacket
Local $packet = TCPRecv($tocTcpSocket, $TOC_MAX_CHAR_RECV)
;~ FileWriteLine(@ScriptDir&"\buffer.txt", $packet)
;~ FileWriteLine(@ScriptDir&"\buffer.txt", "---------")
If $recvCmdBuffer[0] > 0 Then
;~ _ArrayAdd( $recvCmdBuffer, )
$packet = $recvCmdBuffer[1] & $packet
_ArrayDelete($recvCmdBuffer, 1)
$recvCmdBuffer[0] -= 1
EndIf
$decoded = _TocDecodeFlap($packet)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]; first, see if we got the whole packet
If IsArray($decoded) Then
If $decoded[3] <> StringLen($decoded[4]) Then
; if not, enqueue it
_ArrayAdd($recvCmdBuffer, $packet)
$recvCmdBuffer[0] += 1
;~ _DebugPrint( "Doin' a loop to get the whole packet :)" )
; call ourself again to get the rest of the packet
Return _TocGetFlap($iRetType)
EndIf
Else
; not a flap packet, ignore for now
Return -1
EndIf
; now process
If StringLen($packet) > 0 Then
; check for extra commands
If BinaryLen($decoded[5]) > 0 Then
$extraString = $decoded[5]
Do ; loop through, enqueing all COMPLETE packets as separate entries
$newPacket = _TocDecodeFlap($extraString)
; FileWriteLine(@ScriptDir&"\buffer.txt", $extraString)
; FileWriteLine(@ScriptDir&"\buffer.txt", "---------")
If IsArray($newPacket) Then
If $newPacket[0] == "*" Then ; make sure it's actually flap
_ArrayAdd($recvCmdBuffer, StringLeft($extraString, 6 + $newPacket[3]))
$recvCmdBuffer[0] += 1
$extraString = $newPacket[5]
EndIf
Else
$extraString = ""
EndIf
Until $extraString == ""
EndIf
;~ FileWriteLine(@ScriptDir&".\buffer.txt", "-------")
;~ FileWriteLine(@ScriptDir&".\buffer.txt", "Current packet: "&$packet)
;~ FileWriteLine(@ScriptDir&".\buffer.txt", "Excess: " & $decoded[5])
;~ FileWriteLine(@ScriptDir&".\buffer.txt", "Buffer: ")
;~
;~ for $i=1 to $recvCmdBuffer[0]
;~ FileWriteLine(@ScriptDir&".\buffer.txt", $recvCmdBuffer[$i] & @CRLF&"<>"&@CRLF )
;~ Next
;~
;~ FileWriteLine(@ScriptDir&".\buffer.txt", "-------")
_DebugPrint("Received: " & $decoded[4])
Switch $iRetType
Case 0
Return $packet
Case 1
Return $decoded[4]
Case 2
Return StringSplit($decoded[4], ":")
EndSwitch
Else
Return -1
EndIf
EndFunc ;==>_TocGetFlap
;===============================================================================
;
; Description: Convert a number to the necessary binary format, padding the
; beginning with Chr(0) until it's the appropriate $iLength
; Parameter(s): $iNum - The number to be converted
; $iLength - The desired length
; Requirement(s): none
; Return Value(s): The converted number
; Author(s): Dan "Falcone88" Leong
; Note(s): It took me forever to figure out how I was supposed to do this!
; For $iLength:
; byte = 1
; word = 2
; dword = 4
; qword = 8
;
;===============================================================================
Func _BinaryNumber($iNum, $iLength = 2)
Local $b, $numStarted = False, $out = "", $prepend = ""
$b = Binary($iNum)
For $i = BinaryLen($b) To 1 Step -1
If Chr(BinaryMid($b, $i, 1)) <> Chr(0) Or $numStarted Then
If Not $numStarted Then $numStarted = True
$out &= Chr(BinaryMid($b, $i, 1))
EndIf
Next
If BinaryLen($out) < $iLength Then
For $i = 1 To $iLength - BinaryLen($out)
$prepend &= Chr(0)
Next
EndIf
Return $prepend & $out
[/autoit] [autoit][/autoit] [autoit]EndFunc ;==>_BinaryNumber
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func BinaryString($sData)
Local $b = Binary($sData)
Local $out = ""
For $i = 1 To BinaryLen($b)
$out &= Chr(BinaryMid($b, $i, 1))
Next
Return $out
EndFunc ;==>BinaryString
;===============================================================================
;
; Description: Convert a number from the necessary binary format to a
; usable number
; Parameter(s): $iNum - The number to be converted
;
; Requirement(s): none
; Return Value(s): The converted number
; Author(s): Dan "Falcone88" Leong
; Note(s): It took me forever to figure out how I was supposed to do this.
; I finally made this magical. Hopefully it still works
; properly....
;
;===============================================================================
Func _BinaryNumberDecode($iNum)
; A shortcut!
If StringInStr(String($iNum), "0x") Then
$iNum = StringMid(String($iNum), 3)
Return Dec($iNum)
EndIf
$iOffset = 1
While StringMid(String($iNum), $iOffset, 2) == "00"
$iOffset += 2
WEnd
$sTrim = StringMid($iNum, $iOffset)
$iLength = StringLen($sTrim)
$iVal = 0
For $i = 1 To $iLength
$iVal += Number(String(Asc(StringMid($sTrim, $i, 1)))) * (16 ^ (2 * ($iLength - $i)))
Next
Return $iVal
EndFunc ;==>_BinaryNumberDecode
;
; This is not my method, but was very helpful, and I don't want to delete all of the calls
; to it... just in case. So there
;
Func _DebugPrint($s_text)
$s_text = StringReplace($s_text, @LF, @LF & "-->")
ConsoleWrite("!===========================================================" & @LF & _
"+===========================================================" & @LF & _
"-->" & $s_text & @LF & _
"+===========================================================" & @LF)
EndFunc ;==>_DebugPrint
Mein Testaccount hat nur 2 stürzt aber trotzdem ab.
Kann das an AdlibRegister liegen?
Das Autoit nicht mehr hinterherkommt und zuviele Aufrufe auf dem Stack speichert???
Ich hab 2 Accounts und bei beiden stürzt es ab. Manchmal eher, manchmal auch etwas später.
Aber immer noch keine Ahnung woran das liegen könnte
Bei dem Versuch einen ICQ - Client auf Basis der _TocLib zu erstellen, bekomme ich immer wieder folgenden Fehler:
C:\Dokumente und Einstellungen\MasterOne\Desktop\_TocLib.au3 (658 ) : ==> Recursion level has been exceeded - AutoIt will quit to prevent stack overflow.:
$ret[1] = _BinaryNumberDecode( BinaryMid($bPacket, 2, 1) )
Das heißt ja vom Prinzip nichts anderes, eine Funktion zu oft verschachtelt aufgerufen wird?!
Sieht jemand den Grund dafür???
#include "_TocLib.au3"
#include <Timers.au3>
#include <GUIConstants.au3>
OnAutoItExitRegister("_Exit")
[/autoit] [autoit][/autoit] [autoit]Global $User = "123456789"
Global $Pass = "passwort"
$hWnd = GUICreate("ICQ - Ersatz", 280, 300)
$hUser = GUICtrlCreateInput($User, 10, 10, 80, 20)
$hPass = GUICtrlCreateInput($Pass, 100, 10, 80, 20)
$hLogin = GUICtrlCreateButton("Login", 190, 10, 80, 20)
$hList = GUICtrlCreateListView("Nummer|Nickname", 140, 40, 130, 250)
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then Exit
If $msg = $hLogin Then Login()
WEnd
Func HandleRecv($packet)
_DebugPrint("Recieved message: " & $packet)
$msg = _TocParseIm($packet)
;~ If (_Timer_GetIdleTime() > 2000 * 60) Then ;Ist man länger als 2 Minuten abwesend, wird diese Nachricht gesendet:
_TocSendIM($msg[0], "Bin gerade nicht am PC, versuche es bitte später nochmal.", True)
_TocSetAway("PC nicht besetzt!")
;~ EndIf
EndFunc ;==>HandleRecv
Func Config($packet)
_DebugPrint("Config:" & $packet)
$Userlist = _TocParseConfig($packet)
For $i = 0 To UBound($Userlist) - 1
GUICtrlCreateListViewItem($Userlist[$i], $hList)
Next
EndFunc ;==>Config
Func Login()
$login = _TocLogin(GUICtrlRead($hUser), GUICtrlRead($hPass))
If Not $login Then
If @error == $TOC_ERROR Then
_DebugPrint("TOC Error: code " & $login)
Else
_DebugPrint("_TocLogin @error = " & @error)
EndIf
Else
_DebugPrint("Logged in successfully")
GUICtrlSetState($hLogin, $GUI_DISABLE)
EndIf
_TocRegisterFunc($TOC_CMD_CONFIG, "Config")
_TocRegisterFunc($TOC_CMD_IMRECV, "HandleRecv")
_TocInitLoop()
EndFunc ;==>Login
Func _Exit()
_TocCleanup()
EndFunc ;==>_Exit
_TocLib:
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.2.1.12 (beta)
Script Version: 2.1.1.0
Author: Daniel "Falcone88" Leong
Script Function:
My own UDF for the TOC (Talk To Oscar) Protocol
Documentation for the protocol itself may be found in the following:
http://terraim.cvs.sourceforge.net/*checkout*/ter…rc/toc/TOC1.txt
http://terraim.cvs.sourceforge.net/*checkout*/ter…rc/toc/TOC2.txt
The following, though a bit dated, was still very helpful:
http://www2.sys-con.com/ITSG/virtualcd…aton/index.html
If something isn't in the TOC2 docs, it is the same asin TOC1. Note, of course,
that the most recent things (IE: as shown in TOC2) must be used.
List of functions:
_TocLogin
_TocFinalizeLogin
_TocSendIM
_TocSetAway
_TocParseIm
_TocParseConfig <- doesn't do anything yet
_TocCleanup
_TocRegisterFunc
_TocIsRegistered
_TocInitLoop
_TocStopLoop
_TocDoLoop
_TocRoastPass
_TocNormalizeName
_TocNormalizeString
_TocMakeSigninCode
_TocMakeFlapPacket
_TocDecodeFlap
_TocSendFlap
_TocSendRaw
_TocWaitFlap
_TocGetFlap
_BinaryNumber
_BinaryNumberDecode
#ce ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]#include <Array.au3>
[/autoit] [autoit][/autoit] [autoit]; @error codes
Global Const $TOC_TCP_FAIL = 1 ; could not init TCP
Global Const $TOC_CONNECT_FAIL = 2 ; could not connect to toc server
Global Const $TOC_SEND_FAIL = 3 ; could not send over TCP for some reason
Global Const $TOC_ERROR = 4 ; TOC server sent an error code
Global Const $TOC_NO_HANDLERS = 5 ; no functions to handle inputs defined
Global Const $TOC_CMD_TOOLONG = 6 ; attempted to send a string to TOC longer than max
; TOC errors
#cs
* General Errors *
901 - $1 not currently available
902 - Warning of $1 not currently available
903 - A message has been dropped, you are exceeding
the server speed limit
;* Admin Errors *
911 - Error validating input
912 - Invalid account
913 - Error encountered while processing request
914 - Service unavailable
* Chat Errors *
950 - Chat in $1 is unavailable.
* IM & Info Errors *
960 - You are sending message too fast to $1
961 - You missed an im from $1 because it was too big.
962 - You missed an im from $1 because it was sent too fast.
* Dir Errors *
970 - Failure
971 - Too many matches
972 - Need more qualifiers
973 - Dir service temporarily unavailable
974 - Email lookup restricted
975 - Keyword Ignored
976 - No Keywords
977 - Language not supported
-Update: 977 can also mean no directory information available
978 - Country not supported
979 - Failure unknown $1
* Auth errors *
980 - Incorrect nickname or password.
981 - The service is temporarily unavailable.
982 - Your warning level is currently too high to sign on.
983 - You have been connecting and
disconnecting too frequently. Wait 10 minutes and try again.
If you continue to try, you will need to wait even longer.
989 - An unknown signon error has occurred $1
#ce
; TOC Server -> Client commands
Global Const $TOC_CMD_SIGNON = "SIGN_ON"
Global Const $TOC_CMD_IMRECV = "IM_IN_ENC2"
Global Const $TOC_CMD_CONFIG = "CONFIG2"
Global Const $TOC_CMD_BUDDY_ACCEPTED = "NEW_BUDDY_REPLY2"
Global Const $TOC_CMD_CHATRECV = "CHAT_IN_ENC"
Global Const $TOC_CMD_BUDDY_UPDATE = "UPDATE_BUDDY2"
Global Const $TOC_CMD_CHAT_UPDATE = "CHAT_UPDATE_BUDDY"
Global Const $TOC_CMD_CHATINVITE = "CHAT_INVITE"
Global Const $TOC_CMD_ERROR = "ERROR"
Global Const $TOC_CMD_ANY = "~ANY~" ; catches anything not registered otherwise
; FLAP constant crap
$TOC_FLAP_ON = "FLAPON"&@CRLF&@CRLF
$TOC_ROAST_STRING = "Tic/Toc"
$TOC_LANGUAGE = "english"
$TOC_VERSION = "TIC:TOCLib for Autoit by Dan Leong"
$TOC_COUNTRY = "US"
$TOC_MAX_CHAR_LENGTH = 2048
$TOC_MAX_CHAR_RECV = 8192
$TOC_SIGNON_TYPE = 1
$TOC_DATA_TYPE = 2
; global vars
Global $currSequence = 0
Global $tocTcpSocket
Global $tocVersion = ""
Global $handleRecvCmd[1]
Global $handleRecvFunc[1] ; func called on recieved new message
Global $recvCmdBuffer[1] ; in case we recieve messages too fast, we'll throw extra ones into a buffer
;===============================================================================
;
; Description: Login to the TOC Server
; Parameter(s): $sUser - Username for AIM
; $sPass - Password for AIM
; $fFinalize - Whether or not to finalize connection (see notes)
; $sTocServer - TOC Servername. The default should be fine, but
; localhost may be used for testing...
; $iTocPort - TOC port to connect to. Again, default should be fine
; $sAuthServer - Authentication server. (Allows you to login to AIM)
; $iAuthPort - Port of the Auth Server
; Requirement(s): None
; Return Value(s): On Success - true
; On Failure - false and Set
; @ERROR to: $TOC_CONNECT_FAIL - Could not connect to TOC server
; $TOC_SEND_FAIL - Could not send data to the server
; $TOC_ERROR - Recieved an ERROR message from the TOC server
; The error number will be set in @extended
; Author(s): Dan "Falcone88" Leong
; Note(s): If you want to send configurations to the TOC server (say, you're making an AIM client),
; you will want to set this to false, send your config, then use _TocFinalizeLogin(). Note
; that this must be sent within 30 seconds of _TocLogin()'s return, or the server will drop
; the connection.
;
; The comments on the format of the packets were taken from one of the websites at the top
; of this file.
;
;===============================================================================
Func _TocLogin( $sUser, $sPass, $fFinalize=true, $sTocServer="toc.oscar.aol.com", $iTocPort=9898, $sAuthServer="login.oscar.aol.com", $iAuthPort=5190)
If not TCPStartUp() Then
SetError($TOC_TCP_FAIL)
return false
EndIf
$tocTcpSocket = TCPConnect( TCPNameToIP($sTocServer), $iTocPort )
[/autoit] [autoit][/autoit] [autoit]if $tocTcpSocket == -1 Then
SetError($TOC_CONNECT_FAIL)
return false
EndIf
; initialize FLAP
$bytes = _TocSendRaw($TOC_FLAP_ON)
if $bytes == 0 Then
SetError($TOC_SEND_FAIL)
return false
EndIf
_DebugPrint( "Sent FLAPON" )
; wait for TOC version
$tocVersion = _TocWaitFlap()
_DebugPrint( "Recieved TOC Version" )
; send "signon" packet
#cs
First, the version numbers, then a word of 0x0001. This indicates that a user name will follow.
The next word represents the length of the screen name. Following the length is the normalized
representation of the screen name - all spaces are removed and the entire name is converted to lowercase.
#ce
$bytes = _TocSendFlap($tocVersion & BinaryString( "0x0001" ) & ( _BinaryNumber(StringLen($sUser)) ) & _TocNormalizeName($sUser), $TOC_SIGNON_TYPE )
if $bytes == 0 Then
SetError($TOC_SEND_FAIL)
return false
EndIf
_DebugPrint( "Sent SIGNON" )
; login
#cs
toc2_login <address> <port> <screenname> <roasted pw> <language> <version*> 160 US "" "" 3 0 30303 -kentucky -utf8 76144224***
* The version string MUST start with "TIC:" otherwise, no dice. For example, "TIC:AIMM" is ok, but "AIMM2" would be rejected.
** I have no idea what the parameters after the version are. Put them in verbatim and logging in works.
*** See _TocMakeSigninCode()
#ce
$loginStr = 'toc2_login '&$sAuthServer&' '&$iAuthPort&' "'&$sUser&'" '&_TocRoastPass($sPass)&' "'
$loginStr &= $TOC_LANGUAGE&'" "'&$TOC_VERSION&'" 160 '&$TOC_COUNTRY&' "" "" 3 0 30303 -kentucky -utf8 '
$loginStr &= _TocMakeSigninCode($sUser, ($sPass))
$bytes = _TocSendFlap($loginStr)
if $bytes == 0 Then
SetError($TOC_SEND_FAIL)
return false
EndIf
_DebugPrint( "Sent LOGIN" )
$response = _TocWaitFlap(2)
_DebugPrint( _ArrayToString($response, " ") )
if $response[1] = $TOC_CMD_ERROR Then
SetError($TOC_ERROR, StringLeft($response[2], 3), false)
ElseIf $response[1] = $TOC_CMD_SIGNON Then
_DebugPrint("Logged on successfully")
If $fFinalize Then _TocFinalizeLogin()
[/autoit] [autoit][/autoit] [autoit]return true
Else
_DebugPrint("Weird.. I see ("&$response[1]&")")
SetError($TOC_ERROR)
return false
EndIf
return false ; just in case
EndFunc ;==>_TocLogin
;===============================================================================
;
; Description: Finalize login to AIM server
; Parameter(s): None
; Requirement(s): A successful call to _TocLogin()
; Return Value(s): Number of bytes sent via TCP
;
; Author(s): Dan "Falcone88" Leong
; Note(s): See _TocLogin()
;
;===============================================================================
Func _TocFinalizeLogin()
return _TocSendFlap("toc_init_done")
EndFunc ;==>_TocFinalizeLogin()
;===============================================================================
;
; Description: Send an IM to specified user via AIM
; Parameter(s): $sUser - Target user's AIM screenname
; $sMsg - The message to send
; $fAuto - Whether or not to specify the message as an auto response
; Requirement(s): A successful call to _TocLogin()
; Return Value(s): Number of bytes sent via TCP
;
; Author(s): Dan "Falcone88" Leong
; Note(s): None.
;
;===============================================================================
Func _TocSendIM($sUser, $sMsg, $fAuto=false)
Local $packet = 'toc2_send_im '&_TocNormalizeName($sUser)&' "'
$packet &= _TocNormalizeString($sMsg)&'"'
[/autoit] [autoit][/autoit] [autoit]if $fAuto Then $packet &= ' auto'
return _TocSendFlap($packet)
EndFunc ;==>_TocSendIM
;===============================================================================
;
; Description: Set your away message
; Parameter(s): $sMsg - The away message to set
;
; Requirement(s): A successful call to _TocLogin()
; Return Value(s): Number of bytes sent via TCP
;
; Author(s): Dan "Falcone88" Leong
; Note(s): If you call without any arguments, it will set status to
; available.
;
;===============================================================================
Func _TocSetAway($sMsg = "")
return _TocSendFlap('toc_set_away "' & _TocNormalizeString($sMsg) & '"')
EndFunc ;==>_TocSetAway
;===============================================================================
;
; Description: Parse in IM_IN packet from TOC2 into something useful
; Parameter(s): $sPacket - The packet data from IM_IN (Just the data part, not FLAP)
; Requirement(s): Array.au3
; Return Value(s): On Success - An array as follows:
; $ret[0] = username from
; $ret[1] = auto or not (String "T"/"F")
; $ret[2] = buddy status
; $ret[3] = message
; On Failure - "" and Set @ERROR to 1
; Author(s): Dan "Falcone88" Leong
; Note(s): $sPacket SHOULD look like this: (I think)
; <user>:<auto>:<???>:<???>:<buddy status>:<???>:<???>:en:<message>
; Note the omission of IM_IN_ENC2... That's because it's omitted in
; the way _TocDoLoop() calls registered functions
; Alternatively, it can be an array as returned by _TocGetFlap(2)
;
;===============================================================================
Func _TocParseIm( $sPacket )
Local $ret[4], $iMod = 0
if not IsArray($sPacket) Then
$sPacket = StringSplit($sPacket, ":")
Else
$iMod = 1
EndIf
If not IsArray($sPacket) or UBound($sPacket) < 9+$iMod Then
SetError(1)
return ""
EndIf
$ret[0] = $sPacket[1 + $iMod]
$ret[1] = $sPacket[2 + $iMod]
$ret[2] = $sPacket[5 + $iMod]
$ret[3] = _ArrayToString ( $sPacket, ":", 9 + $iMod )
return $ret
EndFunc ;==>_TocParseIm
;===============================================================================
;
; Description: Parse a CONFIG2 packet from TOC2 into something useful
; Parameter(s): $sPacket - The packet data from CONFIG2 (Just the data part, not FLAP)
; Requirement(s): none
; Return Value(s): On Success - An array as follows:
; $ret[0] = 1. Usernumber | Username
; $ret[1] = 2. Usernumber | Username
; $ret[2] = 3. Usernumber | Username
; ...
; Author(s): Dan "Falcone88" Leong
; Note(s): Obviously, this does nothing at the moment. Looking at samples,
; It so far seems pointless to include this, as there's no really
; good way that I can see implementing this as a helpful function
; without using some strange 3d array
;
;===============================================================================
Func _TocParseConfig( $sPacket )
Local $aUsers, $i, $reg
$aUsers = StringRegExp($sPacket, "b:(.*?)" & @LF, 3)
Local $ret[UBound($aUsers)]
For $i = 0 To UBound($aUsers) - 1
$reg = StringRegExp($aUsers[$i] & @LF, "(.*?):(.*?)(?::*)" & @LF, 3)
$ret[$i] = $reg[0] & "|" & BinaryToString(StringToBinary($reg[1], 1), 4) ; User Number & "|" & User Name (UTF8 -> ASCII)
Next
Return $ret
EndFunc ;==>_TocParseConfig
;===============================================================================
;
; Description: Cleanup the TCP connections and such
; Parameter(s): None
; Requirement(s): None
; Return Value(s): None
;
; Author(s): Dan "Falcone88" Leong
; Note(s): None
;
;===============================================================================
Func _TocCleanup()
_TocStopLoop()
TCPCloseSocket( $tocTcpSocket )
TCPShutdown()
EndFunc ;==> _TocCleanup
;
; _TocDoLoop() related functions
;
;===============================================================================
;
; Description: Register a function to be called upon receiving a given command
; Parameter(s): $sCmd - The TOC command to trigger the function
; $sFuncName - Name of the user's function to be called upon recieve
; Requirement(s): Array.au3
; Return Value(s): Always returns true...
; Author(s): Dan "Falcone88" Leong
; Note(s): The function to be called should expect a single argument,
; which will be the exact string arguments provided in the FLAP packet.
;
;===============================================================================
Func _TocRegisterFunc($sCmd, $sFuncName)
$key = _ArraySearch($handleRecvCmd, $sCmd)
if $key == -1 Then
_ArrayAdd($handleRecvCmd, $sCmd)
_ArrayAdd($handleRecvFunc, $sFuncName)
$handleRecvCmd[0] += 1
$handleRecvFunc[0] += 1
Else
$handleRecvFunc[ $key ] = $sFuncName
EndIf
return true
EndFunc ;==>_TocRegisterFunc
;===============================================================================
;
; Description: Check if a particular cmd has a function registered with it
; Parameter(s): $sCmd - The TOC command to trigger the function
; $fReturnIndex - whether to return the index of the cmd (if found)
; instead of a boolean
; Requirement(s): Array.au3
; Return Value(s): On Success - if $fReturnIndex=false, returns TRUE
; if $fReturnIndex=true, returns the index of the func
; On Failure - FALSE
;
; Author(s): Dan "Falcone88" Leong
; Note(s): $fReturnIndex=true is probably not necessary for the casual
; user. I use it as a utility for other functions, though
;
;===============================================================================
Func _TocIsRegistered($sCmd, $fReturnIndex=false)
$key = _ArraySearch($handleRecvCmd, $sCmd)
if $key == -1 Then
return false
Else
if $fReturnIndex Then
return $key
Else
return True
EndIf
EndIf
EndFunc ;==>_TocIsRegistered
;===============================================================================
;
; Description: Initialize the AdLib loop that checks for server input and calls
; the appropriate registered functions.
; Parameter(s): $iDelay - Time in ms between function calls (See definition of AdlibEnable)
; Requirement(s): At least one call to _TocRegisterFunc
; Return Value(s): On Success - true
; On Failure - false and Set @ERROR to $TOC_NO_HANDLERS (No functions registered)
; Author(s): Dan "Falcone88" Leong
; Note(s): none
;
;===============================================================================
Func _TocInitLoop($iDelay=250)
if $handleRecvCmd[0] < 1 Then
SetError( $TOC_NO_HANDLERS )
return false
EndIf
AdlibRegister("_TocDoLoop", $iDelay)
return true
EndFunc ;==>_TocInitLoop
;===============================================================================
;
; Description: Stop the AdLib loop. That's about it
; Parameter(s): none
; Requirement(s): A previous call to _TocInitLoop()... if you want it to do something
; Return Value(s): none
; Author(s): Dan "Falcone88" Leong
; Note(s): none
;
;===============================================================================
Func _TocStopLoop()
AdlibUnRegister()
EndFunc ;==>_TocStopLoop
;===============================================================================
;
; Description: The function called in each loop to parse packets.
; Parameter(s): $iDelay - Time in ms between function calls (See definition of AdlibEnable)
; Requirement(s): Array.au3
; Return Value(s): none
; Author(s): Dan "Falcone88" Leong
; Note(s): When it finds a handled command, it sends the whole
; argument string to that function. The command itself is,
; of course, omitted, as you should know what command it's handling.
;
;===============================================================================
Func _TocDoLoop()
Local $packet, $cmdIndex
$packet = _TocGetFlap(2)
if $packet == -1 Then Return ; nothing
ConsoleWrite("!-- " & $packet[1] & @CRLF)
;~ _DebugPrint( "Recieved: " & _ArrayToString($packet, ":") &@LF& "Looking for: "& $packet[1] )
$cmdIndex = _ArraySearch($handleRecvCmd, $packet[1])
if $cmdIndex == -1 Then
$cmdIndex = _TocIsRegistered($TOC_CMD_ANY, true)
if $cmdIndex == 0 Then Return 0; unhandled cmd, ignore
EndIf
If $cmdIndex == False Then Return 0
Call($handleRecvFunc[$cmdIndex], _ArrayToString($packet,":",2) )
If @error Then MsgBox(0, $cmdIndex, $handleRecvFunc[$cmdIndex])
EndFunc
;
; Util Funcs
;
;===============================================================================
;
; Description: "Roast" a password. Basically it's a really simple encryption
; that TOC requires
; Parameter(s): $sOldPass - The unencrypted password
; Requirement(s): none
; Return Value(s): The "roasted" password
; Author(s): Dan "Falcone88" Leong
; Note(s): none
;
;===============================================================================
Func _TocRoastPass($sOldPass)
Local $roasted = "0x", $xor_i = 1
for $i=1 to StringLen($sOldPass)
$roasted &= hex( BitXOR( Asc(StringMid($TOC_ROAST_STRING, $xor_i, 1)), Asc(StringMid($sOldPass, $i, 1)) ), 2 )
$xor_i += 1
if ( $xor_i > StringLen($TOC_ROAST_STRING) ) Then $xor_i=1
Next
return $roasted
EndFunc ;==>_TocRoastPass
;===============================================================================
;
; Description: "Normalize" a name
; Parameter(s): $sString - The string to "normalize"
; Requirement(s): none
; Return Value(s): The "normalized" name
; Author(s): Dan "Falcone88" Leong
; Note(s): As you can see, this just removes spaces and puts it in lower
; case. This is mostly used for usernames when communicating
; with TOC
;
;===============================================================================
Func _TocNormalizeName($sString)
return StringReplace(StringLower($sString), " ", "")
EndFunc ;==>_TocNormalizeName
;===============================================================================
;
; Description: "Normalize" a string.
; Parameter(s): $sString - The string to "normalize"
; Requirement(s): none
; Return Value(s): The "normalized" string
; Author(s): Dan "Falcone88" Leong
; Note(s): This changes some characters to something more acceptable to
; TOC. This is another function that received help from
; BlueTOC
;
;===============================================================================
Func _TocNormalizeString($sString)
$sString = StringReplace( $sString, "\", "\\" )
$sString = StringReplace( $sString, "$", "\$" )
$sString = StringReplace( $sString, '"', '\"' )
$sString = StringReplace( $sString, "(", "\(" )
$sString = StringReplace( $sString, ")", "\)" )
$sString = StringReplace( $sString, "[", "\[" )
$sString = StringReplace( $sString, "]", "\]" )
$sString = StringReplace( $sString, "{", "\{" )
$sString = StringReplace( $sString, "}", "\}" )
return $sString
EndFunc ;==>_TocNormalizeString
;===============================================================================
;
; Description: Create the wierd authentication code needed to login with TOC2
; Parameter(s): $sUser - the username being used to log in
; $sPass - the password
; Requirement(s): none
; Return Value(s): The code
; Author(s): Ahnugslos (optimized)
; Note(s): Original by Dan "Falcone88" Leong
;
;===============================================================================
Func _TocMakeSigninCode($sUser, $sPass)
return 7696 * Asc(StringLeft($sUser, 1)) * Asc(StringLeft($sPass, 1))
EndFunc ;==>_TocMakeSigninCode
;===============================================================================
;
; Description: Take a TOC command and prepend a FLAP header to it
; Parameter(s): $iType - The type of packet. Can be:
; $TOC_SIGNON_TYPE - used for the signon packet... rarely used
; $TOC_DATA_TYPE - used for nearly everything. Default
; $sData - the command string
; Requirement(s): none
; Return Value(s): The created packet
; Author(s): Dan "Falcone88" Leong
; Note(s): This took me FOREVER to figure out. The most annoying
; part of this whole library, easily
;
;===============================================================================
Func _TocMakeFlapPacket($iType, $sData)
$currSequence += 1
if $iType == $TOC_DATA_TYPE Then $sData &= chr(0)
$btype = _BinaryNumber( $iType, 1 )
$bseq = _BinaryNumber( ($currSequence) )
$blen = _BinaryNumber( StringLen($sData) )
$header = "*" & $btype & $bseq & $blen
[/autoit] [autoit][/autoit] [autoit]return $header & $sData
EndFunc ;==>_TocMakeFlapPacket
;===============================================================================
;
; Description: Decode a raw FLAP packet
; Parameter(s): $bPacket - The packet
;
; Requirement(s): none
; Return Value(s): Success - An array formated as follows:
; $ret[0] = "*"
; $ret[1] = type
; $ret[2] = sequence number
; $ret[3] = length of the packet
; $ret[4] = the packet itself
; $ret[5] = any excess stuff after reading $ret[3] characters
; Failure - The original packet, and sets @ERROR = 1
; Author(s): Dan "Falcone88" Leong
; Note(s): This removes any Chr(0) found in the strings. The fifth index
; is included because sometimes packets are sent quickly and
; become mixed up. This helps to ensure that all packets
; are recieved properly.
;
;===============================================================================
Func _TocDecodeFlap( $bPacket )
If BinaryLen($bPacket) < 1 or Binary( BinaryMid( $bPacket, 1, 1 ) ) <> Binary("*") Then
SetError(1) ; not a proper flap packet, returns full packet
return $bPacket
EndIf
Local $ret[6]
[/autoit] [autoit][/autoit] [autoit]$ret[0] = "*"
$ret[1] = _BinaryNumberDecode( BinaryMid($bPacket, 2, 1) )
$ret[2] = _BinaryNumberDecode( BinaryMid($bPacket, 3, 2) )
$ret[3] = _BinaryNumberDecode( BinaryMid($bPacket, 5, 2) )
$ret[4] = StringMid( BinaryToString($bPacket), 7, $ret[3] )
$ret[5] = StringMid( BinaryToString($bPacket), 7 + $ret[3] )
;~ FileWriteLine(@ScriptDir&"\parsed.txt", "--------")
;~ FileWriteLine(@ScriptDir&"\parsed.txt", " PacketRaw: " & $bPacket)
;~ FileWriteLine(@ScriptDir&"\parsed.txt", "PacketRead: " & $ret[4])
;~ FileWriteLine(@ScriptDir&"\parsed.txt", "Proposed Length: " & $ret[3])
return $ret
EndFunc ;==>_TocDecodeFlap
;===============================================================================
;
; Description: Send a packet to TOC with a FLAP header.
; Parameter(s): $sData - The data string to send
; $iType - type of packet (See _TocMakeFlapPacket)
; $fTruncate - See _TocSendRaw()
;
; Requirement(s): none
; Return Value(s): Number of bytes sent via TCP
; Author(s): Dan "Falcone88" Leong
; Note(s): $iType is second so it can be optional and default to $TOC_DATA_TYPE,
; as that is the most common type
;
;===============================================================================
Func _TocSendFlap( $sData, $iType = 2, $fTruncate=false )
_DebugPrint("SENT: " & $sData)
return _TocSendRaw( _TocMakeFlapPacket($iType, $sData) )
EndFunc ;==>_TocSendFlap
;===============================================================================
;
; Description: Send a raw packet to TOC server
; Parameter(s): $bData - The data string to send
; $fTruncate - Silently clip $bData if it's too long or not
;
; Requirement(s): Previous successful call to _TocLogin()
; Return Value(s): Success - Number of bytes sent via TCP
; Failure - 0, and set @ERROR = $TOC_CMD_TOOLONG
; Author(s): Dan "Falcone88" Leong
; Note(s): Failure condition only ever occurs if $fTruncate = false. If
; $fTruncate = true, this will not issue any errors even if
; the string is longer than allowed ($TOC_MAX_CHAR_LENGTH). It
; will simply truncate the string to the allowed length
;
;===============================================================================
Func _TocSendRaw( $bData, $fTruncate=false )
if not $fTruncate and StringLen($bData) > $TOC_MAX_CHAR_LENGTH Then
SetError($TOC_CMD_TOOLONG)
return 0
EndIf
return TCPSend($tocTcpSocket, StringLeft($bData, $TOC_MAX_CHAR_LENGTH))
EndFunc ;==>_TocSendRaw
;===============================================================================
;
; Description: Wait until a packet is recieved from the TOC server
; Parameter(s): $iRetType - Return format; See _TocGetFlap
;
; Requirement(s): Previous successful call to _TocLogin()
; Return Value(s): See _TocGetFlap
; Author(s): Dan "Falcone88" Leong
; Note(s): none
;
;===============================================================================
Func _TocWaitFlap($iRetType=1)
Local $packet = ""
Do
$packet = _TocGetFlap($iRetType)
Until $packet <> -1
[/autoit] [autoit][/autoit] [autoit]return $packet
EndFunc ;==>_TocWaitFlap
;===============================================================================
;
; Description: Instantaneous (non-blocking) check for a flap packet
; Parameter(s): $iRetType - Format for the return value
;
; Requirement(s): Previous successful call to _TocLogin()
; Return Value(s): Success - Returns the packet, depending on $iRetType:
; 0 - Full packet, raw (including FLAP header)
; 1 - The data part (everything BUT header), raw
; 2 - The data part (everything BUT header), split into
; an array using ":" as the delimeter
; Failure - (No new packet) returns -1
; Author(s): Dan "Falcone88" Leong
; Note(s): This function looks about 25 lines longer than it needs to be,
; but that's because it takes into account packets sent in
; really close proximity that consequently might be interpretted as a single packet.
; Extra packets are added to $recvCmdBuffer and are inserted before the next recieved
; packet in order recieved. (Obviously, there could be a backup if a packet wasn't split up,
; which this method accounts for. However, this is not a problem, as the new packet will
; be found and added to the end of the buffer.
;
;===============================================================================
Func _TocGetFlap($iRetType=0, $fCalledFromLoop=false)
Local $decoded, $extraString, $newPacket
Local $packet = TCPRecv($tocTcpSocket, $TOC_MAX_CHAR_RECV)
;~ FileWriteLine(@ScriptDir&"\buffer.txt", $packet)
;~ FileWriteLine(@ScriptDir&"\buffer.txt", "---------")
if $recvCmdBuffer[0] > 0 Then
;~ _ArrayAdd( $recvCmdBuffer, )
$packet = $recvCmdBuffer[1] & $packet
_ArrayDelete( $recvCmdBuffer, 1 )
$recvCmdBuffer[0] -= 1
EndIf
$decoded = _TocDecodeFlap($packet)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]; first, see if we got the whole packet
If IsArray($decoded) Then
If $decoded[3] <> StringLen($decoded[4]) Then
; if not, enqueue it
_ArrayAdd( $recvCmdBuffer, $packet )
$recvCmdBuffer[0] += 1
;~ _DebugPrint( "Doin' a loop to get the whole packet :)" )
; call ourself again to get the rest of the packet
return _TocGetFlap($iRetType)
EndIf
Else
; not a flap packet, ignore for now
return -1
EndIf
; now process
if StringLen($packet) > 0 Then
; check for extra commands
if BinaryLen($decoded[5]) > 0 Then
$extraString = $decoded[5]
Do ; loop through, enqueing all COMPLETE packets as separate entries
$newPacket = _TocDecodeFlap( $extraString )
FileWriteLine(@ScriptDir&"\buffer.txt", $extraString)
FileWriteLine(@ScriptDir&"\buffer.txt", "---------")
if IsArray($newPacket) Then
if $newPacket[0] == "*" Then ; make sure it's actually flap
_ArrayAdd( $recvCmdBuffer, StringLeft( $extraString, 6 + $newPacket[3]) )
$recvCmdBuffer[0] += 1
$extraString = $newPacket[5]
EndIf
Else
$extraString = ""
EndIf
Until $extraString == ""
EndIf
;~ FileWriteLine(@ScriptDir&".\buffer.txt", "-------")
;~ FileWriteLine(@ScriptDir&".\buffer.txt", "Current packet: "&$packet)
;~ FileWriteLine(@ScriptDir&".\buffer.txt", "Excess: " & $decoded[5])
;~ FileWriteLine(@ScriptDir&".\buffer.txt", "Buffer: ")
;~
;~ for $i=1 to $recvCmdBuffer[0]
;~ FileWriteLine(@ScriptDir&".\buffer.txt", $recvCmdBuffer[$i] & @CRLF&"<>"&@CRLF )
;~ Next
;~
;~ FileWriteLine(@ScriptDir&".\buffer.txt", "-------")
_DebugPrint("Received: " & $decoded[4])
Switch $iRetType
case 0
return $packet
case 1
return $decoded[4]
case 2
return StringSplit($decoded[4], ":")
EndSwitch
Else
return -1
EndIf
EndFunc ;==>_TocGetFlap
;===============================================================================
;
; Description: Convert a number to the necessary binary format, padding the
; beginning with Chr(0) until it's the appropriate $iLength
; Parameter(s): $iNum - The number to be converted
; $iLength - The desired length
; Requirement(s): none
; Return Value(s): The converted number
; Author(s): Dan "Falcone88" Leong
; Note(s): It took me forever to figure out how I was supposed to do this!
; For $iLength:
; byte = 1
; word = 2
; dword = 4
; qword = 8
;
;===============================================================================
Func _BinaryNumber($iNum, $iLength=2)
Local $b, $numStarted=false, $out="", $prepend=""
$b = Binary($iNum)
for $i=BinaryLen($b) to 1 Step -1
if Chr( BinaryMid($b, $i, 1) ) <> Chr(0) or $numStarted Then
if not $numStarted then $numStarted = true
$out &= Chr( BinaryMid($b, $i, 1) )
EndIf
Next
if BinaryLen($out) < $iLength Then
for $i=1 to $iLength-BinaryLen($out)
$prepend &= Chr(0)
Next
EndIf
return $prepend&$out
[/autoit] [autoit][/autoit] [autoit]EndFunc ;==>_BinaryNumber
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func BinaryString ($sData)
Local $b = Binary($sData)
Local $out = ""
for $i=1 to BinaryLen($b)
$out &= Chr( BinaryMid($b, $i, 1) )
Next
return $out
EndFunc
;===============================================================================
;
; Description: Convert a number from the necessary binary format to a
; usable number
; Parameter(s): $iNum - The number to be converted
;
; Requirement(s): none
; Return Value(s): The converted number
; Author(s): Dan "Falcone88" Leong
; Note(s): It took me forever to figure out how I was supposed to do this.
; I finally made this magical. Hopefully it still works
; properly....
;
;===============================================================================
Func _BinaryNumberDecode($iNum)
; A shortcut!
if StringInStr(String($iNum), "0x") Then
$iNum = StringMid(String($iNum),3)
return dec($iNum)
EndIf
$iOffset = 1
While StringMid(String($iNum),$iOffset,2) == "00"
$iOffset+=2
WEnd
$sTrim = StringMid($iNum, $iOffset)
$iLength = StringLen( $sTrim )
$iVal = 0
for $i=1 to $iLength
$iVal += Number( String( Asc( StringMid($sTrim,$i,1) ) ) ) * (16^ (2*($iLength-$i)))
Next
return $iVal
EndFunc ;==>_BinaryNumberDecode
;
; This is not my method, but was very helpful, and I don't want to delete all of the calls
; to it... just in case. So there
;
Func _DebugPrint($s_text)
$s_text = StringReplace($s_text,@LF,@LF & "-->")
ConsoleWrite("!===========================================================" & @LF & _
"+===========================================================" & @LF & _
"-->" & $s_text & @LF & _
"+===========================================================" & @LF)
EndFunc ;==>_DebugPrint
Also ich habe sehr gute Erfahrungen mit Teufel gemacht. Das kleinste Set kostet da aber 149€.
Dafür unterstützt man aber die deutsche Wirtschaft und hat einen sehr guten Kundensupport.
Wobei ich immernoch etwas den alten RFT hinterhertrauer, das war noch richtig solide DDR Handarbeit.
Da hät ich hier die _TocLib UDF von Falcone88:
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.2.1.12 (beta)
Script Version: 2.1.1.0
Author: Daniel "Falcone88" Leong
Script Function:
My own UDF for the TOC (Talk To Oscar) Protocol
Documentation for the protocol itself may be found in the following:
http://terraim.cvs.sourceforge.net/*checkout*/ter…rc/toc/TOC1.txt
http://terraim.cvs.sourceforge.net/*checkout*/ter…rc/toc/TOC2.txt
The following, though a bit dated, was still very helpful:
http://www2.sys-con.com/ITSG/virtualcd…aton/index.html
If something isn't in the TOC2 docs, it is the same asin TOC1. Note, of course,
that the most recent things (IE: as shown in TOC2) must be used.
List of functions:
_TocLogin
_TocFinalizeLogin
_TocSendIM
_TocSetAway
_TocParseIm
_TocParseConfig <- doesn't do anything yet
_TocCleanup
_TocRegisterFunc
_TocIsRegistered
_TocInitLoop
_TocStopLoop
_TocDoLoop
_TocRoastPass
_TocNormalizeName
_TocNormalizeString
_TocMakeSigninCode
_TocMakeFlapPacket
_TocDecodeFlap
_TocSendFlap
_TocSendRaw
_TocWaitFlap
_TocGetFlap
_BinaryNumber
_BinaryNumberDecode
#ce ----------------------------------------------------------------------------
#include <Array.au3>
[/autoit] [autoit][/autoit] [autoit]; @error codes
Global Const $TOC_TCP_FAIL = 1 ; could not init TCP
Global Const $TOC_CONNECT_FAIL = 2 ; could not connect to toc server
Global Const $TOC_SEND_FAIL = 3 ; could not send over TCP for some reason
Global Const $TOC_ERROR = 4 ; TOC server sent an error code
Global Const $TOC_NO_HANDLERS = 5 ; no functions to handle inputs defined
Global Const $TOC_CMD_TOOLONG = 6 ; attempted to send a string to TOC longer than max
; TOC errors
#cs
* General Errors *
901 - $1 not currently available
902 - Warning of $1 not currently available
903 - A message has been dropped, you are exceeding
the server speed limit
;* Admin Errors *
911 - Error validating input
912 - Invalid account
913 - Error encountered while processing request
914 - Service unavailable
* Chat Errors *
950 - Chat in $1 is unavailable.
* IM & Info Errors *
960 - You are sending message too fast to $1
961 - You missed an im from $1 because it was too big.
962 - You missed an im from $1 because it was sent too fast.
* Dir Errors *
970 - Failure
971 - Too many matches
972 - Need more qualifiers
973 - Dir service temporarily unavailable
974 - Email lookup restricted
975 - Keyword Ignored
976 - No Keywords
977 - Language not supported
-Update: 977 can also mean no directory information available
978 - Country not supported
979 - Failure unknown $1
* Auth errors *
980 - Incorrect nickname or password.
981 - The service is temporarily unavailable.
982 - Your warning level is currently too high to sign on.
983 - You have been connecting and
disconnecting too frequently. Wait 10 minutes and try again.
If you continue to try, you will need to wait even longer.
989 - An unknown signon error has occurred $1
#ce
; TOC Server -> Client commands
Global Const $TOC_CMD_SIGNON = "SIGN_ON"
Global Const $TOC_CMD_IMRECV = "IM_IN_ENC2"
Global Const $TOC_CMD_CONFIG = "CONFIG2"
Global Const $TOC_CMD_BUDDY_ACCEPTED = "NEW_BUDDY_REPLY2"
Global Const $TOC_CMD_CHATRECV = "CHAT_IN_ENC"
Global Const $TOC_CMD_BUDDY_UPDATE = "UPDATE_BUDDY2"
Global Const $TOC_CMD_CHAT_UPDATE = "CHAT_UPDATE_BUDDY"
Global Const $TOC_CMD_CHATINVITE = "CHAT_INVITE"
Global Const $TOC_CMD_ERROR = "ERROR"
Global Const $TOC_CMD_ANY = "~ANY~" ; catches anything not registered otherwise
; FLAP constant crap
$TOC_FLAP_ON = "FLAPON"&@CRLF&@CRLF
$TOC_ROAST_STRING = "Tic/Toc"
$TOC_LANGUAGE = "english"
$TOC_VERSION = "TIC:TOCLib for Autoit by Dan Leong"
$TOC_COUNTRY = "US"
$TOC_MAX_CHAR_LENGTH = 2048
$TOC_MAX_CHAR_RECV = 8192
$TOC_SIGNON_TYPE = 1
$TOC_DATA_TYPE = 2
; global vars
Global $currSequence = 0
Global $tocTcpSocket
Global $tocVersion = ""
Global $handleRecvCmd[1]
Global $handleRecvFunc[1] ; func called on recieved new message
Global $recvCmdBuffer[1] ; in case we recieve messages too fast, we'll throw extra ones into a buffer
;===============================================================================
;
; Description: Login to the TOC Server
; Parameter(s): $sUser - Username for AIM
; $sPass - Password for AIM
; $fFinalize - Whether or not to finalize connection (see notes)
; $sTocServer - TOC Servername. The default should be fine, but
; localhost may be used for testing...
; $iTocPort - TOC port to connect to. Again, default should be fine
; $sAuthServer - Authentication server. (Allows you to login to AIM)
; $iAuthPort - Port of the Auth Server
; Requirement(s): None
; Return Value(s): On Success - true
; On Failure - false and Set
; @ERROR to: $TOC_CONNECT_FAIL - Could not connect to TOC server
; $TOC_SEND_FAIL - Could not send data to the server
; $TOC_ERROR - Recieved an ERROR message from the TOC server
; The error number will be set in @extended
; Author(s): Dan "Falcone88" Leong
; Note(s): If you want to send configurations to the TOC server (say, you're making an AIM client),
; you will want to set this to false, send your config, then use _TocFinalizeLogin(). Note
; that this must be sent within 30 seconds of _TocLogin()'s return, or the server will drop
; the connection.
;
; The comments on the format of the packets were taken from one of the websites at the top
; of this file.
;
;===============================================================================
Func _TocLogin( $sUser, $sPass, $fFinalize=true, $sTocServer="toc.oscar.aol.com", $iTocPort=9898, $sAuthServer="login.oscar.aol.com", $iAuthPort=5190)
If not TCPStartUp() Then
SetError($TOC_TCP_FAIL)
return false
EndIf
$tocTcpSocket = TCPConnect( TCPNameToIP($sTocServer), $iTocPort )
if $tocTcpSocket == -1 Then
SetError($TOC_CONNECT_FAIL)
return false
EndIf
; initialize FLAP
$bytes = _TocSendRaw($TOC_FLAP_ON)
if $bytes == 0 Then
SetError($TOC_SEND_FAIL)
return false
EndIf
_DebugPrint( "Sent FLAPON" )
; wait for TOC version
$tocVersion = _TocWaitFlap()
_DebugPrint( "Recieved TOC Version" )
; send "signon" packet
#cs
First, the version numbers, then a word of 0x0001. This indicates that a user name will follow.
The next word represents the length of the screen name. Following the length is the normalized
representation of the screen name - all spaces are removed and the entire name is converted to lowercase.
#ce
$bytes = _TocSendFlap($tocVersion & BinaryString( "0x0001" ) & ( _BinaryNumber(StringLen($sUser)) ) & _TocNormalizeName($sUser), $TOC_SIGNON_TYPE )
if $bytes == 0 Then
SetError($TOC_SEND_FAIL)
return false
EndIf
_DebugPrint( "Sent SIGNON" )
; login
#cs
toc2_login <address> <port> <screenname> <roasted pw> <language> <version*> 160 US "" "" 3 0 30303 -kentucky -utf8 76144224***
* The version string MUST start with "TIC:" otherwise, no dice. For example, "TIC:AIMM" is ok, but "AIMM2" would be rejected.
** I have no idea what the parameters after the version are. Put them in verbatim and logging in works.
*** See _TocMakeSigninCode()
#ce
$loginStr = 'toc2_login '&$sAuthServer&' '&$iAuthPort&' "'&$sUser&'" '&_TocRoastPass($sPass)&' "'
$loginStr &= $TOC_LANGUAGE&'" "'&$TOC_VERSION&'" 160 '&$TOC_COUNTRY&' "" "" 3 0 30303 -kentucky -utf8 '
$loginStr &= _TocMakeSigninCode($sUser, ($sPass))
$bytes = _TocSendFlap($loginStr)
if $bytes == 0 Then
SetError($TOC_SEND_FAIL)
return false
EndIf
_DebugPrint( "Sent LOGIN" )
$response = _TocWaitFlap(2)
_DebugPrint( _ArrayToString($response, " ") )
if $response[1] = $TOC_CMD_ERROR Then
SetError($TOC_ERROR, StringLeft($response[2], 3), false)
ElseIf $response[1] = $TOC_CMD_SIGNON Then
_DebugPrint("Logged on successfully")
If $fFinalize Then _TocFinalizeLogin()
return true
Else
_DebugPrint("Weird.. I see ("&$response[1]&")")
SetError($TOC_ERROR)
return false
EndIf
return false ; just in case
EndFunc ;==>_TocLogin
;===============================================================================
;
; Description: Finalize login to AIM server
; Parameter(s): None
; Requirement(s): A successful call to _TocLogin()
; Return Value(s): Number of bytes sent via TCP
;
; Author(s): Dan "Falcone88" Leong
; Note(s): See _TocLogin()
;
;===============================================================================
Func _TocFinalizeLogin()
return _TocSendFlap("toc_init_done")
EndFunc ;==>_TocFinalizeLogin()
;===============================================================================
;
; Description: Send an IM to specified user via AIM
; Parameter(s): $sUser - Target user's AIM screenname
; $sMsg - The message to send
; $fAuto - Whether or not to specify the message as an auto response
; Requirement(s): A successful call to _TocLogin()
; Return Value(s): Number of bytes sent via TCP
;
; Author(s): Dan "Falcone88" Leong
; Note(s): None.
;
;===============================================================================
Func _TocSendIM($sUser, $sMsg, $fAuto=false)
Local $packet = 'toc2_send_im '&_TocNormalizeName($sUser)&' "'
$packet &= _TocNormalizeString($sMsg)&'"'
if $fAuto Then $packet &= ' auto'
return _TocSendFlap($packet)
EndFunc ;==>_TocSendIM
;===============================================================================
;
; Description: Set your away message
; Parameter(s): $sMsg - The away message to set
;
; Requirement(s): A successful call to _TocLogin()
; Return Value(s): Number of bytes sent via TCP
;
; Author(s): Dan "Falcone88" Leong
; Note(s): If you call without any arguments, it will set status to
; available.
;
;===============================================================================
Func _TocSetAway($sMsg = "")
return _TocSendFlap('toc_set_away "' & _TocNormalizeString($sMsg) & '"')
EndFunc ;==>_TocSetAway
;===============================================================================
;
; Description: Parse in IM_IN packet from TOC2 into something useful
; Parameter(s): $sPacket - The packet data from IM_IN (Just the data part, not FLAP)
; Requirement(s): Array.au3
; Return Value(s): On Success - An array as follows:
; $ret[0] = username from
; $ret[1] = auto or not (String "T"/"F")
; $ret[2] = buddy status
; $ret[3] = message
; On Failure - "" and Set @ERROR to 1
; Author(s): Dan "Falcone88" Leong
; Note(s): $sPacket SHOULD look like this: (I think)
; <user>:<auto>:<???>:<???>:<buddy status>:<???>:<???>:en:<message>
; Note the omission of IM_IN_ENC2... That's because it's omitted in
; the way _TocDoLoop() calls registered functions
; Alternatively, it can be an array as returned by _TocGetFlap(2)
;
;===============================================================================
Func _TocParseIm( $sPacket )
Local $ret[4], $iMod = 0
if not IsArray($sPacket) Then
$sPacket = StringSplit($sPacket, ":")
Else
$iMod = 1
EndIf
If not IsArray($sPacket) or UBound($sPacket) < 9+$iMod Then
SetError(1)
return ""
EndIf
$ret[0] = $sPacket[1 + $iMod]
$ret[1] = $sPacket[2 + $iMod]
$ret[2] = $sPacket[5 + $iMod]
$ret[3] = _ArrayToString ( $sPacket, ":", 9 + $iMod )
return $ret
EndFunc ;==>_TocParseIm
;===============================================================================
;
; Description: Parse a CONFIG2 packet from TOC2 into something useful
; Parameter(s): $sPacket - The packet data from CONFIG2 (Just the data part, not FLAP)
; Requirement(s): Array.au3
; Return Value(s): On Success -
; On Failure -
; Author(s): Dan "Falcone88" Leong
; Note(s): Obviously, this does nothing at the moment. Looking at samples,
; It so far seems pointless to include this, as there's no really
; good way that I can see implementing this as a helpful function
; without using some strange 3d array
;
;===============================================================================
Func _TocParseConfig( $sPacket )
EndFunc ;==>_TocParseConfig
[/autoit] [autoit][/autoit] [autoit];===============================================================================
;
; Description: Cleanup the TCP connections and such
; Parameter(s): None
; Requirement(s): None
; Return Value(s): None
;
; Author(s): Dan "Falcone88" Leong
; Note(s): None
;
;===============================================================================
Func _TocCleanup()
_TocStopLoop()
TCPCloseSocket( $tocTcpSocket )
TCPShutdown()
EndFunc ;==> _TocCleanup
;
; _TocDoLoop() related functions
;
;===============================================================================
;
; Description: Register a function to be called upon receiving a given command
; Parameter(s): $sCmd - The TOC command to trigger the function
; $sFuncName - Name of the user's function to be called upon recieve
; Requirement(s): Array.au3
; Return Value(s): Always returns true...
; Author(s): Dan "Falcone88" Leong
; Note(s): The function to be called should expect a single argument,
; which will be the exact string arguments provided in the FLAP packet.
;
;===============================================================================
Func _TocRegisterFunc($sCmd, $sFuncName)
$key = _ArraySearch($handleRecvCmd, $sCmd)
if $key == -1 Then
_ArrayAdd($handleRecvCmd, $sCmd)
_ArrayAdd($handleRecvFunc, $sFuncName)
$handleRecvCmd[0] += 1
$handleRecvFunc[0] += 1
Else
$handleRecvFunc[ $key ] = $sFuncName
EndIf
return true
EndFunc ;==>_TocRegisterFunc
;===============================================================================
;
; Description: Check if a particular cmd has a function registered with it
; Parameter(s): $sCmd - The TOC command to trigger the function
; $fReturnIndex - whether to return the index of the cmd (if found)
; instead of a boolean
; Requirement(s): Array.au3
; Return Value(s): On Success - if $fReturnIndex=false, returns TRUE
; if $fReturnIndex=true, returns the index of the func
; On Failure - FALSE
;
; Author(s): Dan "Falcone88" Leong
; Note(s): $fReturnIndex=true is probably not necessary for the casual
; user. I use it as a utility for other functions, though
;
;===============================================================================
Func _TocIsRegistered($sCmd, $fReturnIndex=false)
$key = _ArraySearch($handleRecvCmd, $sCmd)
if $key == -1 Then
return false
Else
if $fReturnIndex Then
return $key
Else
return True
EndIf
EndIf
EndFunc ;==>_TocIsRegistered
;===============================================================================
;
; Description: Initialize the AdLib loop that checks for server input and calls
; the appropriate registered functions.
; Parameter(s): $iDelay - Time in ms between function calls (See definition of AdlibEnable)
; Requirement(s): At least one call to _TocRegisterFunc
; Return Value(s): On Success - true
; On Failure - false and Set @ERROR to $TOC_NO_HANDLERS (No functions registered)
; Author(s): Dan "Falcone88" Leong
; Note(s): none
;
;===============================================================================
Func _TocInitLoop($iDelay=250)
if $handleRecvCmd[0] < 1 Then
SetError( $TOC_NO_HANDLERS )
return false
EndIf
AdlibEnable("_TocDoLoop", $iDelay)
return true
EndFunc ;==>_TocInitLoop
;===============================================================================
;
; Description: Stop the AdLib loop. That's about it
; Parameter(s): none
; Requirement(s): A previous call to _TocInitLoop()... if you want it to do something
; Return Value(s): none
; Author(s): Dan "Falcone88" Leong
; Note(s): none
;
;===============================================================================
Func _TocStopLoop()
AdLibDisable()
EndFunc ;==>_TocStopLoop
;===============================================================================
;
; Description: The function called in each loop to parse packets.
; Parameter(s): $iDelay - Time in ms between function calls (See definition of AdlibEnable)
; Requirement(s): Array.au3
; Return Value(s): none
; Author(s): Dan "Falcone88" Leong
; Note(s): When it finds a handled command, it sends the whole
; argument string to that function. The command itself is,
; of course, omitted, as you should know what command it's handling.
;
;===============================================================================
Func _TocDoLoop()
Local $packet, $cmdIndex
$packet = _TocGetFlap(2)
if $packet == -1 Then Return ; nothing
;~ _DebugPrint( "Recieved: " & _ArrayToString($packet, ":") &@LF& "Looking for: "& $packet[1] )
$cmdIndex = _ArraySearch($handleRecvCmd, $packet[1])
if $cmdIndex == -1 Then
$cmdIndex = _TocIsRegistered($TOC_CMD_ANY, true)
if $cmdIndex == -1 Then return ; unhandled cmd, ignore
EndIf
Call( $handleRecvFunc[$cmdIndex], _ArrayToString($packet,":",2) )
EndFunc
;
; Util Funcs
;
;===============================================================================
;
; Description: "Roast" a password. Basically it's a really simple encryption
; that TOC requires
; Parameter(s): $sOldPass - The unencrypted password
; Requirement(s): none
; Return Value(s): The "roasted" password
; Author(s): Dan "Falcone88" Leong
; Note(s): none
;
;===============================================================================
Func _TocRoastPass($sOldPass)
Local $roasted = "0x", $xor_i = 1
for $i=1 to StringLen($sOldPass)
$roasted &= hex( BitXOR( Asc(StringMid($TOC_ROAST_STRING, $xor_i, 1)), Asc(StringMid($sOldPass, $i, 1)) ), 2 )
$xor_i += 1
if ( $xor_i > StringLen($TOC_ROAST_STRING) ) Then $xor_i=1
Next
return $roasted
EndFunc ;==>_TocRoastPass
;===============================================================================
;
; Description: "Normalize" a name
; Parameter(s): $sString - The string to "normalize"
; Requirement(s): none
; Return Value(s): The "normalized" name
; Author(s): Dan "Falcone88" Leong
; Note(s): As you can see, this just removes spaces and puts it in lower
; case. This is mostly used for usernames when communicating
; with TOC
;
;===============================================================================
Func _TocNormalizeName($sString)
return StringReplace(StringLower($sString), " ", "")
EndFunc ;==>_TocNormalizeName
;===============================================================================
;
; Description: "Normalize" a string.
; Parameter(s): $sString - The string to "normalize"
; Requirement(s): none
; Return Value(s): The "normalized" string
; Author(s): Dan "Falcone88" Leong
; Note(s): This changes some characters to something more acceptable to
; TOC. This is another function that received help from
; BlueTOC
;
;===============================================================================
Func _TocNormalizeString($sString)
$sString = StringReplace( $sString, "\", "\\" )
$sString = StringReplace( $sString, "$", "\$" )
$sString = StringReplace( $sString, '"', '\"' )
$sString = StringReplace( $sString, "(", "\(" )
$sString = StringReplace( $sString, ")", "\)" )
$sString = StringReplace( $sString, "[", "\[" )
$sString = StringReplace( $sString, "]", "\]" )
$sString = StringReplace( $sString, "{", "\{" )
$sString = StringReplace( $sString, "}", "\}" )
return $sString
EndFunc ;==>_TocNormalizeString
;===============================================================================
;
; Description: Create the wierd authentication code needed to login with TOC2
; Parameter(s): $sUser - the username being used to log in
; $sPass - the password
; Requirement(s): none
; Return Value(s): The code
; Author(s): Dan "Falcone88" Leong (Conversion to AutoIt)
; Note(s): Borrowed from BlueTOC, the PHP library for TOC2. Original
; comments are left intact
;
;===============================================================================
Func _TocMakeSigninCode($sUser, $sPass)
Local $un, $pn, $a, $b, $c
; We get the ascii value of the first character of
; the username and password and then we subtract
; 96 from each value
$un = asc( StringLeft($sUser, 1) ) - 96
$pn = asc( StringLeft($sPass, 1) ) - 96
; Then we do some math
$a = $un * 7696 + 738816;
$b = $un * 746512;
$c = $pn * $a;
; And then we have some weird signon code we need
return $c - $a + $b + 71665152;
EndFunc ;==>_TocMakeSigninCode
;===============================================================================
;
; Description: Take a TOC command and prepend a FLAP header to it
; Parameter(s): $iType - The type of packet. Can be:
; $TOC_SIGNON_TYPE - used for the signon packet... rarely used
; $TOC_DATA_TYPE - used for nearly everything. Default
; $sData - the command string
; Requirement(s): none
; Return Value(s): The created packet
; Author(s): Dan "Falcone88" Leong
; Note(s): This took me FOREVER to figure out. The most annoying
; part of this whole library, easily
;
;===============================================================================
Func _TocMakeFlapPacket($iType, $sData)
$currSequence += 1
if $iType == $TOC_DATA_TYPE Then $sData &= chr(0)
$btype = _BinaryNumber( $iType, 1 )
$bseq = _BinaryNumber( ($currSequence) )
$blen = _BinaryNumber( StringLen($sData) )
$header = "*" & $btype & $bseq & $blen
return $header & $sData
EndFunc ;==>_TocMakeFlapPacket
;===============================================================================
;
; Description: Decode a raw FLAP packet
; Parameter(s): $bPacket - The packet
;
; Requirement(s): none
; Return Value(s): Success - An array formated as follows:
; $ret[0] = "*"
; $ret[1] = type
; $ret[2] = sequence number
; $ret[3] = length of the packet
; $ret[4] = the packet itself
; $ret[5] = any excess stuff after reading $ret[3] characters
; Failure - The original packet, and sets @ERROR = 1
; Author(s): Dan "Falcone88" Leong
; Note(s): This removes any Chr(0) found in the strings. The fifth index
; is included because sometimes packets are sent quickly and
; become mixed up. This helps to ensure that all packets
; are recieved properly.
;
;===============================================================================
Func _TocDecodeFlap( $bPacket )
If BinaryLen($bPacket) < 1 or Binary( BinaryMid( $bPacket, 1, 1 ) ) <> Binary("*") Then
SetError(1) ; not a proper flap packet, returns full packet
return $bPacket
EndIf
Local $ret[6]
$ret[0] = "*"
$ret[1] = _BinaryNumberDecode( BinaryMid($bPacket, 2, 1) )
$ret[2] = _BinaryNumberDecode( BinaryMid($bPacket, 3, 2) )
$ret[3] = _BinaryNumberDecode( BinaryMid($bPacket, 5, 2) )
$ret[4] = StringMid( BinaryToString($bPacket), 7, $ret[3] )
$ret[5] = StringMid( BinaryToString($bPacket), 6 + $ret[3] )
;~ FileWriteLine(@ScriptDir&"\parsed.txt", "--------")
;~ FileWriteLine(@ScriptDir&"\parsed.txt", " PacketRaw: " & $bPacket)
;~ FileWriteLine(@ScriptDir&"\parsed.txt", "PacketRead: " & $ret[4])
;~ FileWriteLine(@ScriptDir&"\parsed.txt", "Proposed Length: " & $ret[3])
return $ret
EndFunc ;==>_TocDecodeFlap
;===============================================================================
;
; Description: Send a packet to TOC with a FLAP header.
; Parameter(s): $sData - The data string to send
; $iType - type of packet (See _TocMakeFlapPacket)
; $fTruncate - See _TocSendRaw()
;
; Requirement(s): none
; Return Value(s): Number of bytes sent via TCP
; Author(s): Dan "Falcone88" Leong
; Note(s): $iType is second so it can be optional and default to $TOC_DATA_TYPE,
; as that is the most common type
;
;===============================================================================
Func _TocSendFlap( $sData, $iType = 2, $fTruncate=false )
_DebugPrint("SENT: " & $sData)
return _TocSendRaw( _TocMakeFlapPacket($iType, $sData) )
EndFunc ;==>_TocSendFlap
;===============================================================================
;
; Description: Send a raw packet to TOC server
; Parameter(s): $bData - The data string to send
; $fTruncate - Silently clip $bData if it's too long or not
;
; Requirement(s): Previous successful call to _TocLogin()
; Return Value(s): Success - Number of bytes sent via TCP
; Failure - 0, and set @ERROR = $TOC_CMD_TOOLONG
; Author(s): Dan "Falcone88" Leong
; Note(s): Failure condition only ever occurs if $fTruncate = false. If
; $fTruncate = true, this will not issue any errors even if
; the string is longer than allowed ($TOC_MAX_CHAR_LENGTH). It
; will simply truncate the string to the allowed length
;
;===============================================================================
Func _TocSendRaw( $bData, $fTruncate=false )
if not $fTruncate and StringLen($bData) > $TOC_MAX_CHAR_LENGTH Then
SetError($TOC_CMD_TOOLONG)
return 0
EndIf
return TCPSend($tocTcpSocket, StringLeft($bData, $TOC_MAX_CHAR_LENGTH))
EndFunc ;==>_TocSendRaw
;===============================================================================
;
; Description: Wait until a packet is recieved from the TOC server
; Parameter(s): $iRetType - Return format; See _TocGetFlap
;
; Requirement(s): Previous successful call to _TocLogin()
; Return Value(s): See _TocGetFlap
; Author(s): Dan "Falcone88" Leong
; Note(s): none
;
;===============================================================================
Func _TocWaitFlap($iRetType=1)
Local $packet = ""
Do
$packet = _TocGetFlap($iRetType)
Until $packet <> -1
return $packet
EndFunc ;==>_TocWaitFlap
;===============================================================================
;
; Description: Instantaneous (non-blocking) check for a flap packet
; Parameter(s): $iRetType - Format for the return value
;
; Requirement(s): Previous successful call to _TocLogin()
; Return Value(s): Success - Returns the packet, depending on $iRetType:
; 0 - Full packet, raw (including FLAP header)
; 1 - The data part (everything BUT header), raw
; 2 - The data part (everything BUT header), split into
; an array using ":" as the delimeter
; Failure - (No new packet) returns -1
; Author(s): Dan "Falcone88" Leong
; Note(s): This function looks about 25 lines longer than it needs to be,
; but that's because it takes into account packets sent in
; really close proximity that consequently might be interpretted as a single packet.
; Extra packets are added to $recvCmdBuffer and are inserted before the next recieved
; packet in order recieved. (Obviously, there could be a backup if a packet wasn't split up,
; which this method accounts for. However, this is not a problem, as the new packet will
; be found and added to the end of the buffer.
;
;===============================================================================
Func _TocGetFlap($iRetType=0, $fCalledFromLoop=false)
Local $packet = "", $decoded, $extraString, $newPacket
$packet = TCPRecv($tocTcpSocket, $TOC_MAX_CHAR_RECV)
if $recvCmdBuffer[0] > 0 Then
;~ _ArrayAdd( $recvCmdBuffer, )
$packet = $recvCmdBuffer[1] & $packet
_ArrayDelete( $recvCmdBuffer, 1 )
$recvCmdBuffer[0] -= 1
EndIf
$decoded = _TocDecodeFlap($packet)
; first, see if we got the whole packet
If IsArray($decoded) Then
If $decoded[3] <> StringLen($decoded[4]) Then
; if not, enqueue it
_ArrayAdd( $recvCmdBuffer, $packet )
$recvCmdBuffer[0] += 1
;~ _DebugPrint( "Doin' a loop to get the whole packet :)" )
; call ourself again to get the rest of the packet
return _TocGetFlap($iRetType)
EndIf
Else
; not a flap packet, ignore for now
return -1
EndIf
; now process
if StringLen($packet) > 0 Then
; check for extra commands
if $decoded[5] <> "" Then
$extraString = $decoded[5]
Do ; loop through, enqueing all COMPLETE packets as separate entries
$newPacket = _TocDecodeFlap( $extraString )
if IsArray($newPacket) Then
if $newPacket[0] == "*" Then ; make sure it's actually flap
_ArrayAdd( $recvCmdBuffer, StringLeft( $extraString, 6 + $newPacket[3] ) )
$recvCmdBuffer[0] += 1
$extraString = $newPacket[5]
EndIf
Else
$extraString = ""
EndIf
Until $extraString == ""
EndIf
;~ FileWriteLine(@ScriptDir&".\buffer.txt", "-------")
;~ FileWriteLine(@ScriptDir&".\buffer.txt", "Current packet: "&$packet)
;~ FileWriteLine(@ScriptDir&".\buffer.txt", "Excess: " & $decoded[5])
;~ FileWriteLine(@ScriptDir&".\buffer.txt", "Buffer: ")
;~
;~ for $i=1 to $recvCmdBuffer[0]
;~ FileWriteLine(@ScriptDir&".\buffer.txt", $recvCmdBuffer[$i] & @CRLF&"<>"&@CRLF )
;~ Next
;~
;~ FileWriteLine(@ScriptDir&".\buffer.txt", "-------")
_DebugPrint("Received: " & $decoded[4])
Switch $iRetType
case 0
return $packet
case 1
return $decoded[4]
case 2
return StringSplit($decoded[4], ":")
EndSwitch
Else
return -1
EndIf
EndFunc ;==>_TocGetFlap
;===============================================================================
;
; Description: Convert a number to the necessary binary format, padding the
; beginning with Chr(0) until it's the appropriate $iLength
; Parameter(s): $iNum - The number to be converted
; $iLength - The desired length
; Requirement(s): none
; Return Value(s): The converted number
; Author(s): Dan "Falcone88" Leong
; Note(s): It took me forever to figure out how I was supposed to do this!
; For $iLength:
; byte = 1
; word = 2
; dword = 4
; qword = 8
;
;===============================================================================
Func _BinaryNumber($iNum, $iLength=2)
Local $b, $numStarted=false, $out="", $prepend=""
$b = Binary($iNum)
for $i=BinaryLen($b) to 1 Step -1
if Chr( BinaryMid($b, $i, 1) ) <> Chr(0) or $numStarted Then
if not $numStarted then $numStarted = true
$out &= Chr( BinaryMid($b, $i, 1) )
EndIf
Next
if BinaryLen($out) < $iLength Then
for $i=1 to $iLength-BinaryLen($out)
$prepend &= Chr(0)
Next
EndIf
return $prepend&$out
EndFunc ;==>_BinaryNumber
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func BinaryString ($sData)
Local $b = Binary($sData)
Local $out = ""
for $i=1 to BinaryLen($b)
$out &= Chr( BinaryMid($b, $i, 1) )
Next
return $out
EndFunc
;===============================================================================
;
; Description: Convert a number from the necessary binary format to a
; usable number
; Parameter(s): $iNum - The number to be converted
;
; Requirement(s): none
; Return Value(s): The converted number
; Author(s): Dan "Falcone88" Leong
; Note(s): It took me forever to figure out how I was supposed to do this.
; I finally made this magical. Hopefully it still works
; properly....
;
;===============================================================================
Func _BinaryNumberDecode($iNum)
; A shortcut!
if StringInStr(String($iNum), "0x") Then
$iNum = StringMid(String($iNum),3)
return dec($iNum)
EndIf
$iOffset = 1
While StringMid(String($iNum),$iOffset,2) == "00"
$iOffset+=2
WEnd
$sTrim = StringMid($iNum, $iOffset)
$iLength = StringLen( $sTrim )
$iVal = 0
for $i=1 to $iLength
$iVal += Number( String( Asc( StringMid($sTrim,$i,1) ) ) ) * (16^ (2*($iLength-$i)))
Next
return $iVal
EndFunc ;==>_BinaryNumberDecode
;
; This is not my method, but was very helpful, and I don't want to delete all of the calls
; to it... just in case. So there
;
Func _DebugPrint($s_text)
$s_text = StringReplace($s_text,@LF,@LF & "-->")
ConsoleWrite("!===========================================================" & @LF & _
"+===========================================================" & @LF & _
"-->" & $s_text & @LF & _
"+===========================================================" & @LF)
EndFunc ;==>_DebugPrint
So wie 2 recht ausführliche Erklärungen zum Oscar Protokoll:
TOC2.0 documentation and misc TOC notes
Jeffrey Rosen - jeff@emuscene.com
Updated by George Vulov - georgevulov@hotmail.com
First of all, lets start with some old TOC1.0 stuff:
toc_get_status <screenname>
This useful command wasn't ever really documented. It returns either an UPDATE_BUDDY message or an ERROR
message depending on whether or not the guy appears to be online.
Misc TOC notes:
If you connect with an empty buddy list, other people can't see you online. You can work around this by
simply sending "toc_add_buddy a" if the user's buddy list is empty. This has been corrected in TOC2.0.
In TOC1.0 there is a toc_add_deny command, but no toc_remove_deny. In order to remove people from your
block list, you need to send a "toc_add_permit" command and then send your entire deny list without the
screenname you want to unblock. Reverse the deny and permit commands if you want to add someone to your
permit list. Again, TOC2.0 fixes this.
Now for TOC2.0:
**************** CLIENT -> SERVER: ****************
---------------------------------------------
Connecting:
Connect to aimexpress.oscar.aol.com, not toc.oscar.aol.com, otherwise retrieving profiles
will not work without much refreshing.
---------------------------------------------
The sign on process is essentially the same as in TOC1.0 except AOL added some questionable parameters to it:
toc2_login <address> <port> <screenname> <roasted pw> <language> <version*> 160 US "" "" 3 0 30303 -kentucky -utf8 76144224***
* The version string MUST start with "TIC:" otherwise, no dice. For example, "TIC:AIMM" is ok, but "AIMM2" would be rejected.
** I have no idea what the parameters after the version are. Put them in verbatim and logging in works.
*** This is a simple code created with the first letter of the screen name and password. Here is some generic code:
sn = ascii value of the first letter of the screen name
pw = ascii value of the first character of the password
return 7696 * sn * pw
For example, if the screenname was "test" and the password was "x5435" the result would be 107128320.
---------------------------------------------
The permit/deny stuff has been seriously revamped. There's not much else you could ask for:
toc2_set_pdmode <value>
Value:
1 - Allow all (default)
2 - Block all
3 - Allow "permit group" only
4 - Block "deny group" only
5 - Allow buddy list only
Pretty self explanatory. You can manage your permit/deny groups using the commands below:
toc2_add_permit <screenname>
toc2_remove_permit <screenname>
toc2_add_deny <screenname>
toc2_remove_deny <screenname>
<screenname> should be normalized and you can add multiple people at a time by separating the
screennames with a space. Unlike in TOC1.0, these don't cause funky behaviors. That is, you
can access these whenever you feel like and thanks to the new pdmode function, you no longer
will have to resort to cheap hacks to get these to work correctly.
(Read: no more wildly flickering on other people's buddy lists!)
Note: In TOC2.0 these are all automatically added to your config. More on that later.
---------------------------------------------
Buddy list commands have also been seriously revamped:
toc2_new_group <group>
toc2_del_group <group>
This is an entirely new command that allows you to add groups. These should be quoted and you can't
add more than one per command. This can be worked around using the new_buddies command though.
---------------------------------------------
toc2_new_buddies <config format*>
In TOC2.0, you must add buddies in "config format". See example:
{g:test<lf*>b:buddytest:alias1<lf>b:buddytest2:alias2<lf>}
If you sent that with the toc2_new_buddies command, you would add the two buddies (buddytest and buddytest2)
with aliases alias1 and alias2 into the group "test". Note that if the group doesn't already exist, it will be created.
Alternatively, if the usernames didn't have aliases, they would be added as follows:
{g:test<lf*>b:buddytest<lf>b:buddytest2<lf>}
* <lf> stands for linefeed, '\n'. Don't literally send "<LF>"
---------------------------------------------
toc2_remove_buddy <screenname> <group>
Pretty self explanatory. You can remove multiple names in the same group using the syntax <screenname> <screenname> <group>.
---------------------------------------------
toc2_send_im <user> <message> <auto>
This seems to be the same as in TOC1.0.
---------------------------------------------
toc2_client_event <user> <typing status>
This is used to send a typing notification.
0 for no activity, 1 for typing paused, 2 for currently typing.
**************** SERVER -> CLIENT: ****************
---------------------------------------------
CONFIG2:<config>
The only difference between CONFIG2 and CONFIG is that instead of "b buddy1", for example, it would be "b:buddy1".
Also, the last item is always "done:<lf>".
TOC2 has also added support for server-stored aliases. A user's server-stored alias, if they have one, is right
after the username, separated by a colon.
A word about configs: in TOC2.0, everything is automatically saved to your config and your config is automatically
loaded when you sign on. That is, you don't have to read the config and manually add all the buddies. If they show
up in the config, they've already been added.
---------------------------------------------
NEW_BUDDY_REPLY2:<buddy>:<action>
This shows up after you add a buddy. The action can be either "added", which means that the buddy
was added correctly, or "auth" which is used in ICQ to siginify that that user has requested
authorization to you to their buddy list.
---------------------------------------------
IM_IN_ENC2:<user>:<auto>:<???>:<???>:<buddy status>:<???>:<???>:en:<message>
This command received instead of IM_IN. It is similar to TOC 1.0 except there are a few new parameters.
One of them is language and another is the buddy status, but the rest are unknown.
---------------------------------------------
CHAT_IN_ENC:<chatroom id>:<user>:<whisper T/F>:<???>:en:<message>
This command received instead of CHAT_IN. It is similar to TOC 1.0 except there are a two new parameters.
One of them is language; the other is unknown but is usually "A"
---------------------------------------------
UPDATE_BUDDY2:<screenname>:<online>:<warning>:<signon Time>:<idletime>:<userclass>:<???>
Same as TOC1.0 except there's a mystery parameter.
---------------------------------------------
UPDATED2:b:<username>:<unknown>:<alias>
We receive this when somebody's server-stored alias is updated.
---------------------------------------------
INSERTED2:g:<group name>
A new group has been added to the buddy list.
INSERTED2:b:<alias>:<username>:<group>
A new screenname has been added.
INSERTED2:d:<username>
Somebody has been added to the deny list.
INSERTED2:p:<username>
Somebody has been added to the permit list.
These will be sent whenever the buddy list is modified from a different location, which happens
when one is logged in in two different places. It's a good idea to handle these, otherwise
the buddy list displayed could become out of synch with what's on the server.
---------------------------------------------
DELETED2:g:<group name>
A group has been deleted from the buddy list.
DELETED2:b:<username>:<group>
A user has been deleted from the buddy list.
DELETED2:d:<username>
A user had been removed from the deny list.
DELETED2:p:<username>
A user has been removed from the permit list.
These commands are similar to the INSERTED2 commands, in that they provide dynamic
updates whenever the buddy list is modified from a different location.
---------------------------------------------
CLIENT_EVENT2:<username>:<typing status>
These are typing notifications. 0 means stopped, 1 means text entered, and 2 means typing.
---------------------------------------------
BUDDY_CAPS2:<username>:<capability1>,<capability2>,...
This packet describes a particular user's capabilities, such
as file transfer, buddy icons, ect.
---------------------------------------------
BART2:<username>:<unknown>
The structure of this message is not yet understood. It most likely provides buddy icon
information about a user, such as whether they have a buddy icon or not and
the hashcode necessary to request if from the server.
Original Copyright Message:
# Copyright (c) 1998-9 America Online, Inc. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Updated by Justin Mazzola Paluska <jmp@mit.edu> using notes from a
file named "toc2.txt" containing the following header:
TOC2.0 documentation and misc TOC notes
Jeffrey Rosen - jeff@emuscene.com
######################################################################
Version: TOC2.0
This document describes the protocol between TOC and TOC clients.
The protocol is built on TCP. Framing is done by SFLAP,
described at the bottom of this document. Inside each
SFLAP frame is a TOC command.
The TOC protocol is ASCII based, and special attention
must be placed argument separation. The separator and
the rules of separation are different for messages inbound
to TOC and outbound to the client. The rules of separation
are described in sections below.
The TOC server is built mainly to service the TIC and TiK clients. Since
the TIC client is a Java applet, and downloadable, TOC will NOT support
multiple TOC protocol versions at the same time. Therefore, TiK
users will be forced to upgrade if the protocol version changes.
TOC sends down the protocol version it expects the client
to speak and understand. Note, the protocol version is a string.
Important Notes
===============
* TOC will drop the connection if a command exceeds the maximum
length, which is currently 2048 bytes. So the client needs to
spend special attention to im, chat, and config message lengths.
There is an 8k length maximum from TOC to the client.
* No commands should be sent to TOC (besides toc_signon) before
a SIGN_ON is received. If you do send a command before SIGN_ON
the command will be ignored, and in some case the connection
will be dropped.
* After TOC sends the PAUSE message to a client, all messages sent
to TOC will be ignored, and in some cases the connection will
be dropped. Another SIGN_ON message will be sent to the client
when it is online again. The buddy list and permit/deny items must
be sent again, followed by the toc_init_done. In most cases the
SIGN_ON message will be sent between 1-2 seconds after the
PAUSE message. Therefore a client could choose to ignore the
PAUSE message and hope nothing bad happens.
Client -> TOC
==============
The commands and the arguments are usually separated by whitespaces. Arguments
with whitespace characters should be enclosed in quotes. Dollar signs,
curly brackets, square brackets, parentheses, quotes, and backslashes
must all be backslashed whether in quotes or not. It is usually
a good idea just to use quotes no matter what. All user names from clients
to TOC should be normalized (spaces removed and lowercased), and therefore
are the one exception to the always use quotes rule.
When sending commands to the server you will not get a response
back confirming that the command format was correct or not! However
in some cases if the command format was incorrect the connection
will be dropped.
RoastingString="Tic/Toc"
toc2_signon <authorizer host> <authorizer port> <User Name> <Password>
<language> <version> <???> <code>
The password needs to be roasted with the Roasting String if
coming over a FLAP connection, CP connections don't use
roasted passwords. The language specified will be used
when generating web pages, such as the get info pages.
Currently the only supported language is "english".
If the language sent isn't found, the default "english"
language will be used. The version string will be used
for the client identity, and must be less then 50
characters.
Passwords are roasted when sent to the host. This is done so they
aren't sent in "clear text" over the wire, although they are still
trivial to decode. Roasting is performed by first xoring each byte
in the password with the equivalent modulo byte in the roasting
string. The result is then converted to ascii hex, and prepended
with "0x". So for example the password "password" roasts to
"0x2408105c23001130"
The unknown field <???> is usually 160, though other numbers seem
to work.
The code is created with the first letter of the screen name and
password. Here is some generic code based on some code Nuix
provided:
sn = ascii value of the first letter of the screen name - 96
pw = ascii value of the first character of the password - 96
a = sn * 7696 + 738816
b = sn * 746512
c = pw * a
return c - a + b + 71665152
For example, if the screenname was "test" and the password was
"x5435" the result would be 107128320.
toc_init_done
Tells TOC that we are ready to go online. TOC clients should first
send TOC the buddy list and any permit/deny lists. However toc_init_done
must be called within 30 seconds after toc_signon, or the connection
will be dropped. Remember, it can't be called until after the SIGN_ON
message is received. Calling this before or multiple times after a
SIGN_ON will cause the connection to be dropped.
toc2_send_im <Destination User> <Message> [auto]
Send a message to a remote user. Remember to quote and encode the
message. If the optional string "auto" is the last argument, then the
auto response flag will be turned on for the im.
toc2_new_group <group>
This is an entirely new command that allows you to add groups.
These should be quoted and you can't add more than one per command.
This can be worked around using the new_buddies command though.
toc2_del_group <group>
Remove a buddy group. <group> must be quoted.
toc2_new_buddies <config format*>
In TOC2.0, you must add buddies in "config format". See example:
g:test<lf>
b:buddytest<lf>
b:buddytest2<lf>
b:buddytest3<lf>
If you sent that with the toc2_new_buddies command, you would add
the three buddies (buddytest, buddytest2, and buddytest3) into the
group "test". Note that if the group doesn't already exist, it
will be created.
<lf> stands for linefeed (ASCII:10). Don't literally send "<LF>"
toc2_remove_buddy <screenname> <group>
Remove screenname from group. You can remove multiple names in the
same group using the syntax <screenname> <screenname> <group>.
toc_set_config <Config Info>
Set the config information for this user. The config information
is line oriented with the first character being the item type,
followed by a colon, with the rest of the line being the item
value. Only letters, numbers, and spaces should be used. Remember
you will have to enclose the entire config in quotes.
Item Types:
g - Buddy Group (All Buddies until the next g or the end of config
are in this group.)
b - A Buddy
p - Person on permit list
d - Person on deny list
m - Permit/Deny Mode. Possible values are
1 - Permit All
2 - Deny All
3 - Permit Some
4 - Deny Some
toc_evil <User> <norm|anon>
Evil/Warn someone else. The 2nd argument is either the string
"norm" for a normal warning, or "anon" for an anonymous
warning. You can only evil people who have recently sent you
ims. The higher someones evil level, the slower they can
send message.
toc2_set_pdmode <value>
Set your "permit/deny" visibility.
Value:
1 - Allow all (default)
2 - Block all
3 - Allow "permit group" only
4 - Block "deny group" only
5 - Allow buddy list only
toc2_add_permit [ <User 1> [<User 2> [...]]]
ADD the following people to your permit mode.
toc2_remove_permit [ <User 1> [<User 2> [...]]]
REMOVE the following people to your permit mode.
toc2_add_deny [ <User 1> [<User 2> [...]]]
ADD the following people to your deny mode.
toc2_remove_deny [ <User 1> [<User 2> [...]]]
REMOVE the following people to your deny mode.
toc_chat_join <Exchange> <Chat Room Name>
Join a chat room in the given exchange. Exchange is
an integer that represents a group of chat rooms.
Different exchanges have different properties. For
example some exchanges might have room replication (ie
a room never fills up, there are just multiple
instances.) and some exchanges might have navigational
information, and some exchanges might have ... Currently
exchange should always be 4, however this may
change in the future. You will either
receive an ERROR if the room couldn't be joined
or a CHAT_JOIN message. The Chat Room Name
is case insensitive and consecutive spaces
are removed.
toc_chat_send <Chat Room ID> <Message>
Send a message in a chat room using the chat room
id from CHAT_JOIN. Since reflection is always on in
TOC, you do not need to add the message to your chat UI,
since you will get a CHAT_IN with the message.
Remember to quote and encode the message.
toc_chat_whisper <Chat Room ID> <dst_user> <Message>
Send a message in a chat room using the chat room
id from CHAT_JOIN. This message is directed at
only one person. (Currently you DO need to add this to
your UI.) Remember to quote and encode the message.
Chat whispering is different from IMs since it is linked
to a chat room, and should usually be displayed in the chat
room UI.
toc_chat_evil <Chat Room ID> <User> <norm|anon>
Evil/Warn someone else inside a chat room. The 3rd argument is either
the string "norm" for a normal warning, or "anon" for an anonymous
warning. Currently chat evil is not turned on in the chat complex.
toc_chat_invite <Chat Room ID> <Invite Msg> <buddy1> [<buddy2> [<buddy3> [...]]]
Once you are inside a chat room you can invite other people into
that room. Remember to quote and encode the invite message.
toc_chat_leave <Chat Room ID>
Leave the chat room.
toc_chat_accept <Chat Room ID>
Accept a CHAT_INVITE message from TOC. The server will send a
CHAT_JOIN in response.
toc_get_info <username>
Gets a user's info a GOTO_URL or ERROR message will be sent back to the
client.
toc_set_info <info information>
Set the LOCATE user information. This is basic HTML.
Remember to encode the info.
toc_set_away [<away message>]
if the away message is present, then the unavailable
status flag is set for the user. If the away message
is not present, then the unavailable status flag is
unset. The away message is basic HTML, remember to
encode the information.
toc_get_dir <username>
Gets a user's dir info a GOTO_URL or ERROR message will be sent back to the
client.
toc_set_dir <info information>
Set the DIR user information. This is a colon separated fields as in:
"first name":"middle name":"last name":"maiden name":"city":"state":"country":"email":"allow web searches"
Should return a DIR_STATUS msg. Having anything in the "allow web searches"
field allows people to use web-searches to find your directory info.
Otherwise, they'd have to use the client.
toc_dir_search <info information>
Perform a search of the Oscar Directory, using colon separated fields as in:
"first name":"middle name":"last name":"maiden name":"city":"state":"country":"email"
Returns either a GOTO_URL or ERROR msg.
toc_set_idle <idle secs>
Set idle information. If <idle secs> is 0 then the user isn't idle at all.
If <idle secs> is greater then 0 then the user has already been idle
for <idle secs> number of seconds. The server will automatically
keep incrementing this number, so do not repeatedly call with new
idle times.
toc_set_caps [ <Capability 1> [<Capability 2> [...]]]
Set my capabilities. All capabilities that we support need to
be sent at the same time. Capabilities are represented by
UUIDs.
toc_rvous_propose - Not Implemented Yet
toc_rvous_accept <nick> <cookie> <service> <tlvlist>
Accept a rendezvous proposal from the user <nick>.
<cookie> is the cookie from the RVOUS_PROPOSE
message. <service> is the UUID the proposal was
for. <tlvlist> contains a list of tlv tags followed by
base64 encoded values.
toc_rvous_cancel <nick> <cookie> <service> <tlvlist>
Cancel a rendezvous proposal from the user <nick>.
<cookie> is the cookie from the RVOUS_PROPOSE
message. <service> is the UUID the proposal was
for. <tlvlist> contains a list of tlv tags followed by
base64 encoded values.
toc_format_nickname <new_format>
Reformat a user's nickname. An ADMIN_NICK_STATUS or ERROR message will
be sent back to the client.
toc_change_passwd <existing_passwd new_passwd>
Change a user's password. An ADMIN_PASSWD_STATUS or ERROR message will
be sent back to the client.
TOC -> Client
==============
All user names from TOC to client are NOT normalized, and are
sent as they should be displayed. String are NOT encoded, instead
we use colons as separators. So that you can have colons inside
of messages, everything after the colon before :<Message> should
be considered part of the message (ie don't just "split" on colons,
instead split with a max number of results.)
SIGN_ON:<Client Version Supported>
This is sent after a successful toc_signon command is sent to TOC.
If the command was unsuccessful either the FLAP connection will
be dropped or you will receive a ERROR message.
CONFIG2:<config>
A user's config. Config can be empty in which case the host was not able to
retrieve it, or a config didn't exist for the user. See toc_set_config
above for the format.
CONFIG:<config>
A user's config. Config can be empty in which case the host was not able to
retrieve it, or a config didn't exist for the user. See toc_set_config
above for the format.
NICK:<Nickname>
Tells you your correct nickname (ie how it should be capitalized and
spacing)
IM_IN2:<Source User>:<Auto Response T/F?>:<???><Message>
Receive an IM from some one. Everything after the fourth colon is
the incoming message, including other colons.
NEW_BUDDY_REPLY2:<buddy>:<action>
This shows up after you add a buddy confirming that it was added
correctly or something. Maybe if you're at your buddy list maximum
it returns an error? If the buddy was added successfully, action is
"added".
UPDATE_BUDDY2:<Buddy User>:<Online? T/F>:<Evil Amount>:<Signon Time>:<IdleTime>:<UC>:<???>
This one command handles arrival/depart/updates. Evil Amount is
a percentage, Signon Time is UNIX epoc, idle time is in minutes, UC (User Class)
is a two/three character string.
uc[0]:
' ' - Ignore
'A' - On AOL
uc[1]
' ' - Ignore
'A' - Oscar Admin
'U' - Oscar Unconfirmed
'O' - Oscar Normal
uc[2]
'\0' - Ignore
' ' - Ignore
'U' - The user has set their unavailable flag.
The function of the last parameter is unknown.
ERROR:<Error Code>:Var args
* General Errors *
901 - $1 not currently available
902 - Warning of $1 not currently available
903 - A message has been dropped, you are exceeding
the server speed limit
* Admin Errors *
911 - Error validating input
912 - Invalid account
913 - Error encountered while processing request
914 - Service unavailable
* Chat Errors *
950 - Chat in $1 is unavailable.
* IM & Info Errors *
960 - You are sending message too fast to $1
961 - You missed an im from $1 because it was too big.
962 - You missed an im from $1 because it was sent too fast.
* Dir Errors *
970 - Failure
971 - Too many matches
972 - Need more qualifiers
973 - Dir service temporarily unavailable
974 - Email lookup restricted
975 - Keyword Ignored
976 - No Keywords
977 - Language not supported
978 - Country not supported
979 - Failure unknown $1
* Auth errors *
980 - Incorrect nickname or password.
981 - The service is temporarily unavailable.
982 - Your warning level is currently too high to sign on.
983 - You have been connecting and
disconnecting too frequently. Wait 10 minutes and try again.
If you continue to try, you will need to wait even longer.
989 - An unknown signon error has occurred $1
EVILED:<new evil>:<name of eviler, blank if anonymous>
The user was just eviled.
CHAT_JOIN:<Chat Room Id>:<Chat Room Name>
We were able to join this chat room. The Chat Room Id is
internal to TOC.
CHAT_IN:<Chat Room Id>:<Source User>:<Whisper? T/F>:<Message>
A chat message was sent in a chat room.
CHAT_UPDATE_BUDDY:<Chat Room Id>:<Inside? T/F>:<User 1>:<User 2>...
This one command handles arrival/departs from a chat room. The
very first message of this type for each chat room contains the
users already in the room.
CHAT_INVITE:<Chat Room Name>:<Chat Room Id>:<Invite Sender>:<Message>
We are being invited to a chat room.
CHAT_LEFT:<Chat Room Id>
Tells tic connection to chat room has been dropped
GOTO_URL:<Window Name>:<Url>
Goto a URL. Window Name is the suggested internal name of the window
to use. (Java supports this.)
DIR_STATUS:<Return Code>:<Optional args>
<Return Code> is always 0 for success status.
ADMIN_NICK_STATUS:<Return Code>:<Optional args>
<Return Code> is always 0 for success status.
ADMIN_PASSWD_STATUS:<Return Code>:<Optional args>
<Return Code> is always 0 for success status.
PAUSE
Tells TIC to pause so we can do migration
RVOUS_PROPOSE:<user>:<uuid>:<cookie>:<seq>:<rip>:<pip>:<vip>:<port>
[:tlv tag1:tlv value1[:tlv tag2:tlv value2[:...]]]
Another user has proposed that we rendezvous with them to
perform the service specified by <uuid>. They want us
to connect to them, we have their rendezvous ip, their
proposer_ip, and their verified_ip. The tlv values are
base64 encoded.
Typical Signon Process
======================
Except for the section marked optional this is an sequential
process. Each line MUST occur before the following line.
* Client connects to TOC
* Client sends "FLAPON\r\n\r\n"
* TOC sends Client FLAP SIGNON
* Client sends TOC FLAP SIGNON
* Client sends TOC "toc_signon" message
* if login fails TOC drops client's connection
else TOC sends client SIGN_ON reply
* if Client doesn't support version it drops the connection
[BEGIN OPTIONAL]
* TOC sends Client CONFIG
[END OPTIONAL]
* Client sends TOC toc_init_done message
SFLAP Documentation
===================
SFLAP is pretty much a FLAP connection except the DATA frame payload is a null
terminated string when traveling from client to host, it is NOT null
terminated when traveling from host to client. The FLAP Header is binary
data, and is in network byte order. The data portion is at offset 6, after the
header. The sequence number is sequential in each direction. So
packets from the server to client have one sequence number, while
the packets from the client to server have an independent
increasing number.
FLAP Header (6 bytes)
-----------
Offset Size Type
0 1 ASTERISK (literal ASCII '*')
1 1 Frame Type
2 2 Sequence Number
4 2 Data Length
Valid Frame Type Values
-----------------------
1 SIGNON
2 DATA
3 ERROR (Not used by TOC)
4 SIGNOFF (Not used by TOC)
5 KEEP_ALIVE
TOC SIGNON FRAME TYPE
---------------------
Sequence Number contains the initial sequence number used in each direction.
Data Length contains the payload length, with the payload described
below. The payload area is NOT null terminated.
Host To Client:
4 byte FLAP version (1)
Client To Host:
4 byte FLAP version (1)
2 byte TLV Tag (1)
2 byte Normalized User Name Length
N byte Normalized User Name (NOT null terminated)
TOC DATA FRAME TYPE
-------------------
Sequence Number contains the next sequence number.
Data Length is the length of the payload, including the null termination
from client to host.
Fragen dazu kannst du gerne Stellen. Wenn ich ihn finde, lad ich noch nen kleinen ICQ Clint rauf.