1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-28 22:06:38 +02:00

Reintroduce /upgrade command, working only with core and IRC plugin today

Command will be improved in near future and other plugins like xfer
will be modified to manage upgrade process.
This commit is contained in:
Sebastien Helleu
2008-08-19 23:22:52 +02:00
parent ff1983533b
commit b76d7e4a5c
68 changed files with 4122 additions and 3725 deletions
+6 -2
View File
@@ -12,6 +12,8 @@
./src/core/wee-debug.h
./src/core/wee-hook.c
./src/core/wee-hook.h
./src/core/wee-infolist.c
./src/core/wee-infolist.h
./src/core/wee-input.c
./src/core/wee-input.h
./src/core/wee-list.c
@@ -24,6 +26,8 @@
./src/core/wee-string.h
./src/core/wee-upgrade.c
./src/core/wee-upgrade.h
./src/core/wee-upgrade-file.c
./src/core/wee-upgrade-file.h
./src/core/wee-utf8.c
./src/core/wee-utf8.h
./src/core/wee-util.c
@@ -130,8 +134,6 @@
./src/plugins/plugin-config.c
./src/plugins/plugin-config.h
./src/plugins/plugin.h
./src/plugins/plugin-infolist.c
./src/plugins/plugin-infolist.h
./src/plugins/scripts/lua/weechat-lua-api.c
./src/plugins/scripts/lua/weechat-lua-api.h
./src/plugins/scripts/lua/weechat-lua.c
@@ -178,3 +180,5 @@
./src/plugins/xfer/xfer.h
./src/plugins/xfer/xfer-network.c
./src/plugins/xfer/xfer-network.h
./src/plugins/xfer/xfer-upgrade.c
./src/plugins/xfer/xfer-upgrade.h
+108 -58
View File
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-07-10 17:35+0200\n"
"POT-Creation-Date: 2008-08-13 16:43+0200\n"
"PO-Revision-Date: 2007-09-06 12:44+0200\n"
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -560,6 +560,18 @@ msgstr "není na kanále"
msgid "%d option(s) reset, %d option(s) removed"
msgstr "%d volba/volby resetovány, %d volba/volby smazány"
#, fuzzy
msgid "Upgrading WeeChat..."
msgstr "Terminál ztracen, ukončuji WeeChat..."
#, fuzzy, c-format
msgid "%sError: unable to save session in file"
msgstr "%s selhalo uložení nastavení pluginů\n"
#, c-format
msgid "Error: exec failed (program: \"%s\"), exiting WeeChat"
msgstr ""
#, c-format
msgid "WeeChat uptime: %d %s %02d:%02d:%02d, started on %s"
msgstr "Čas běhu WeeChat: %d %s %02d:%02d:%02d, spuštěn %s"
@@ -723,7 +735,8 @@ msgstr ""
msgid ""
"filter messages in buffers, to hide/show them according to tags or regex"
msgstr ""
"filtrovat zprávy v bufferu, pro jejich schováni/zobrazení podle tagů nebo regulárního výrazu"
"filtrovat zprávy v bufferu, pro jejich schováni/zobrazení podle tagů nebo "
"regulárního výrazu"
msgid ""
"[list] | [enable|disable|toggle] | [add buffer tags regex] | [del number]"
@@ -752,8 +765,8 @@ msgstr ""
" add: přidat filtr\n"
" del: smazat filtr\n"
" číslo: číslo filtru pro smazání (podívejte se na list pro nalezení)\n"
" buffer: buffer kde je filtr aktivní: může to být jméno (kategorie.jméno) nebo "
"\"*\" pro všechny buffery\n"
" buffer: buffer kde je filtr aktivní: může to být jméno (kategorie.jméno) "
"nebo \"*\" pro všechny buffery\n"
" tagy: čárkami rozdělený seznam tagů, například: \"irc_join,irc_part,"
"irc_quit\"\n"
" regex: regulární výraz hledaný v řádku (použíjte \\t pro oddělení prefixu "
@@ -908,11 +921,11 @@ msgid ""
"According to option, it's reset (for standard options) or removed (for "
"optional settings, like server values)."
msgstr ""
"volba: jméno volby (může být začátek nebo konec s \"*\" pro hromadný "
"reset voleb, používejte obezřetně!).\n"
"volba: jméno volby (může být začátek nebo konec s \"*\" pro hromadný reset "
"voleb, používejte obezřetně!).\n"
"\n"
"Podle volby je volba resetována (pro standardní volby) nebo odebrána "
"(pro nepovinné volby jako hodnoty serveru)."
"Podle volby je volba resetována (pro standardní volby) nebo odebrána (pro "
"nepovinné volby jako hodnoty serveru)."
msgid "upgrade WeeChat without disconnecting from servers"
msgstr "aktualizovat WeeChat bez odpojení od serveru"
@@ -1457,22 +1470,22 @@ msgstr "upozornit uživatele pokud nastane částečné doplnění"
msgid ""
"partially complete nicks (stop when many nicks found begin with same letters)"
msgstr ""
"částečně doplňovat přezdívky (zastavit pokud je nalezeno více přezdívek začínajících "
"stejnými písmenemy)"
"částečně doplňovat přezdívky (zastavit pokud je nalezeno více přezdívek "
"začínajících stejnými písmenemy)"
msgid ""
"partially complete command names (stop when many commands found begin with "
"same letters)"
msgstr ""
"částečně doplňovat jména příkazů (zastavit pokud je nalezeno více příkazů začínajících "
"stejnými písmeny)"
"částečně doplňovat jména příkazů (zastavit pokud je nalezeno více příkazů "
"začínajících stejnými písmeny)"
msgid ""
"partially complete command arguments (stop when many arguments found begin "
"with same prefix)"
msgstr ""
"částečně doplňovat argumenty příkazů (zastavit pokud je nalezeno více argumentů "
"začínající stejným prefixem)"
"částečně doplňovat argumenty příkazů (zastavit pokud je nalezeno více "
"argumentů začínající stejným prefixem)"
msgid "display count for each partial completion in bar item"
msgstr "zobrazit počet každého částečného doplnění v položce pole"
@@ -1528,15 +1541,15 @@ msgid ""
"enable debug messages by default in all plugins (option disabled by default, "
"which is highly recommended)"
msgstr ""
"povolit ladící zprávy defaultně ve všech pluginech (volba je defaultně vypnuta, "
"což je velice doporučeno)"
"povolit ladící zprávy defaultně ve všech pluginech (volba je defaultně "
"vypnuta, což je velice doporučeno)"
msgid ""
"standard plugins extension in filename (for example \".so\" under Linux or "
"\".dll\" under Microsoft Windows)"
msgstr ""
"standardní přípona souboru pluginů (například \".so\" pod Linuxem nebo \".dll\" "
"pod Microsoft Windows)"
"standardní přípona souboru pluginů (například \".so\" pod Linuxem nebo \".dll"
"\" pod Microsoft Windows)"
msgid ""
"path for searching plugins ('%h' will be replaced by WeeChat home, ~/."
@@ -1670,39 +1683,24 @@ msgstr ""
"s jiným domovským adresářem pomocí \"--dir\" volby příkazové řádky.\n"
#, c-format
msgid ""
"Last operation with session file was at position %ld, read of %d bytes\n"
msgstr "Poslední operace se souborem sezení bzla na pozici %ld, čtu %d bytů\n"
#, c-format
msgid ""
"Please send %s/%s, %s/%s and above messages to WeeChat developers for "
"support.\n"
"Be careful, private info may be in these files.\n"
msgid "%sError upgrading WeeChat:"
msgstr ""
"Prosím pošlete %s/%s, %s/%s a zprávu nahoře vývojářům WeeChat pro podporu.\n"
"Opatrně v souborech můžou být soukromé informace.\n"
#, fuzzy, c-format
msgid "%s error: %s"
msgstr "%sServer: %s%s\n"
#, c-format
msgid "wrong type in file (expected: %d, read: %d)"
msgstr "špatný typ v souboru (očekáván: %d, přečten: %d)"
msgid "%s last read: position: %ld, length: %d"
msgstr ""
msgid "invalid length for a buffer"
msgstr "nevalidní délka pro buffer"
msgid "object read error"
msgstr "chyba při čtení objektu"
#, fuzzy, c-format
msgid "%s source: %s, line: %d"
msgstr " napsal \"%s\", licence: %s"
#, c-format
msgid "wrong object (expected: %d, read: %d)"
msgstr "špatný objekt (očekáván: %d, přečten: %d)"
msgid "type read error"
msgstr "chyba při čtení typu"
#, c-format
msgid "wrong type (expected: %d, read: %d)"
msgstr "špatný typ (očekáván: %d, přečten: %d)"
msgid "%s*** Please report above info to developers ***"
msgstr ""
#, fuzzy, c-format
msgid "Error: cannot create directory \"%s\"\n"
@@ -1766,15 +1764,15 @@ msgid ""
"bar filling direction (\"horizontal\" (from left to right) or \"vertical"
"\" (from top to bottom)) when bar position is top or bottom"
msgstr ""
"směr plnění pole (\"horizontal\" (z leva do prava) nebo \"vertical\" "
"(z hora dolů)) když je pozice pole nahoře nebo dole"
"směr plnění pole (\"horizontal\" (z leva do prava) nebo \"vertical\" (z hora "
"dolů)) když je pozice pole nahoře nebo dole"
msgid ""
"bar filling direction (\"horizontal\" (from left to right) or \"vertical"
"\" (from top to bottom)) when bar position is left or right"
msgstr ""
"směr plnění pole (\"horizontal\" (z leva do prava) nebo \"vertical\" "
"(z hora dolů)) když je pozice pole vlevo nebo vpravo"
"směr plnění pole (\"horizontal\" (z leva do prava) nebo \"vertical\" (z hora "
"dolů)) když je pozice pole vlevo nebo vpravo"
msgid "bar size in chars (0 = auto size)"
msgstr "velikost pole ve znacích (0 = automatická velikost)"
@@ -2001,7 +1999,8 @@ msgstr "%sdemo zpráva s chybovým prefixem"
#, c-format
msgid "colors: %s buffer %s nick1 %s nick2 %s nick3 %s nick4"
msgstr "barvy: %s buffer %s přezdívka1 %s přezdívka2 %s přezdívka3 %s přezdívka4"
msgstr ""
"barvy: %s buffer %s přezdívka1 %s přezdívka2 %s přezdívka3 %s přezdívka4"
#, fuzzy, c-format
msgid "%s%s: missing argument for \"%s\" command (try /help %s)"
@@ -4043,7 +4042,8 @@ msgstr ""
" reset: resetovat úroveň notifikace do výchozí hodnoty\n"
" none: buffer nikdy nebude v hotlistu\n"
"highlight: buffer bude v hotlistu pouze při zvýraznění\n"
" message: buffer bude v hotlistu pouze při zvýraznění a uživatelských zprávách\n"
" message: buffer bude v hotlistu pouze při zvýraznění a uživatelských "
"zprávách\n"
" all: buffer bude v hotlistu pro jakýkoliv vytištěný text"
#, fuzzy, c-format
@@ -4511,19 +4511,21 @@ msgstr "vyčisti hotlist"
msgid ""
"%3d. %s (%s), file: \"%s\" (local: \"%s\"), %s %s, status: %s%s%s (%lu %%)"
msgstr ""
"%3d. %s (%s), soubor: \"%s\" (lokální: \"%s\"), %s %s, status: %s%s%s (%lu %%)"
"%3d. %s (%s), soubor: \"%s\" (lokální: \"%s\"), %s %s, status: %s%s%s (%lu %"
"%)"
#, c-format
msgid "%3d. %s, chat with %s (local nick: %s), started on %s, status: %s%s"
msgstr "%3d. %s, komunikace s %s (lokální přezdívka: %s), začalo %s, status: %s%s"
msgstr ""
"%3d. %s, komunikace s %s (lokální přezdívka: %s), začalo %s, status: %s%s"
#, c-format
msgid ""
" plugin: %s (id: %s), file: %lu bytes (position: %lu), address: %d.%d.%d."
"%d (port %d)"
msgstr ""
" plugin: %s (id: %s), soubor: %lu bytů (pozice: %lu), adresa: %d.%d.%d.%d"
" (port %d)"
" plugin: %s (id: %s), soubor: %lu bytů (pozice: %lu), adresa: %d.%d.%d.%"
"d (port %d)"
#, c-format
msgid " fast_send: %s, blocksize: %d, started on %s"
@@ -4545,7 +4547,8 @@ msgid "Open buffer with xfer list"
msgstr "Otevřené buffery s xfer seznamem"
msgid "auto open xfer buffer when a new xfer is added to list"
msgstr "automaticky otevřít xfer buffer, když je přidána nová položka do xfer seznamu"
msgstr ""
"automaticky otevřít xfer buffer, když je přidána nová položka do xfer seznamu"
msgid "size of progress bar, in chars (if 0, progress bar is disabled)"
msgstr "velikost ukazatele průběhu ve znacích (0 pro vypnutí ukazatele)"
@@ -4618,7 +4621,8 @@ msgstr ""
msgid ""
"speed limit for sending files, in kilo-bytes by second (0 means no limit)"
msgstr ""
"rychlostní limit pro posílání souboru, v kilobytech za sekundu (0 znamená žádný limit)"
"rychlostní limit pro posílání souboru, v kilobytech za sekundu (0 znamená "
"žádný limit)"
#, fuzzy
msgid "path for writing incoming files"
@@ -4631,7 +4635,9 @@ msgstr ""
"cesta)"
msgid "use remote nick as prefix in local filename when receiving a file"
msgstr "použít vzdálenou přezdívku jako prefix lokálního souboru při přijímání souboru"
msgstr ""
"použít vzdálenou přezdívku jako prefix lokálního souboru při přijímání "
"souboru"
msgid "convert spaces to underscores when sending files"
msgstr "konvertovat mezery na podtržítka při odesílání souborů"
@@ -4696,3 +4702,47 @@ msgstr "%s DCC: nemohu nastavit 'neblokovaci' volbu na soket\n"
#, fuzzy, c-format
msgid "%s%s: timeout for \"%s\" with %s"
msgstr "%s chybí argument pro volbu \"%s\"\n"
#, fuzzy
#~ msgid "write of infolist type 'integer'"
#~ msgstr " . typ: celočíselný\n"
#, fuzzy
#~ msgid "unable to create infolist"
#~ msgstr "%s DCC: nemohu vytvořit rouru\n"
#, fuzzy
#~ msgid "unable to create infolist item"
#~ msgstr "%s DCC: nemohu vytvořit rouru\n"
#~ msgid ""
#~ "Last operation with session file was at position %ld, read of %d bytes\n"
#~ msgstr ""
#~ "Poslední operace se souborem sezení bzla na pozici %ld, čtu %d bytů\n"
#~ msgid ""
#~ "Please send %s/%s, %s/%s and above messages to WeeChat developers for "
#~ "support.\n"
#~ "Be careful, private info may be in these files.\n"
#~ msgstr ""
#~ "Prosím pošlete %s/%s, %s/%s a zprávu nahoře vývojářům WeeChat pro "
#~ "podporu.\n"
#~ "Opatrně v souborech můžou být soukromé informace.\n"
#~ msgid "wrong type in file (expected: %d, read: %d)"
#~ msgstr "špatný typ v souboru (očekáván: %d, přečten: %d)"
#~ msgid "invalid length for a buffer"
#~ msgstr "nevalidní délka pro buffer"
#~ msgid "object read error"
#~ msgstr "chyba při čtení objektu"
#~ msgid "wrong object (expected: %d, read: %d)"
#~ msgstr "špatný objekt (očekáván: %d, přečten: %d)"
#~ msgid "type read error"
#~ msgstr "chyba při čtení typu"
#~ msgid "wrong type (expected: %d, read: %d)"
#~ msgstr "špatný typ (očekáván: %d, přečten: %d)"
+75 -45
View File
@@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-07-10 17:35+0200\n"
"POT-Creation-Date: 2008-08-13 16:43+0200\n"
"PO-Revision-Date: 2007-09-06 12:44+0200\n"
"Last-Translator: Thomas Schuetz <i18n@internet-villa.de>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -564,6 +564,18 @@ msgstr "Sie sind nicht im Channel"
msgid "%d option(s) reset, %d option(s) removed"
msgstr ""
#, fuzzy
msgid "Upgrading WeeChat..."
msgstr "Aktualisiere WeeChat...\n"
#, fuzzy, c-format
msgid "%sError: unable to save session in file"
msgstr "%s kann die Sitzung nicht in eine Datei speichern\n"
#, fuzzy, c-format
msgid "Error: exec failed (program: \"%s\"), exiting WeeChat"
msgstr "%s Ausführung schlug fehl (Programm: \"%s\"), WeeChat wird beendet\n"
#, c-format
msgid "WeeChat uptime: %d %s %02d:%02d:%02d, started on %s"
msgstr "WeeChat Uptime: %d %s %02d:%02d:%02d, gestartet am %s"
@@ -1625,44 +1637,25 @@ msgstr ""
"durch das Benutzen der \"--dir\" Kommandozeilenoption mit einem anderen Home-"
"Verzeichnis zu starten.\n"
#, fuzzy, c-format
msgid "%sError upgrading WeeChat:"
msgstr "Aktualisiere WeeChat...\n"
#, fuzzy, c-format
msgid "%s error: %s"
msgstr "%sServer: %s%s\n"
#, c-format
msgid ""
"Last operation with session file was at position %ld, read of %d bytes\n"
msgid "%s last read: position: %ld, length: %d"
msgstr ""
"Der letzte Zugriff auf die Sitzungsdatei war bei Position %ld, %d Bytes "
"gelesen.\n"
#, c-format
msgid ""
"Please send %s/%s, %s/%s and above messages to WeeChat developers for "
"support.\n"
"Be careful, private info may be in these files.\n"
msgid "%s source: %s, line: %d"
msgstr ""
"Bitte senden Sie %s/%s, %s/%s und die obigen Nachrichten an die WeeChat-"
"Entwickler um Support zu erhalten.\n"
"Beachten Sie bitte, dass in diesen Dateien persönliche Informationen "
"enthalten sein können.\n"
#, c-format
msgid "wrong type in file (expected: %d, read: %d)"
msgstr "Falscher Datentyp in der Datei (erwartet: %d, gefunden: %d)"
msgid "invalid length for a buffer"
msgstr "Fehlerhafte Pufferlänge"
msgid "object read error"
msgstr "Objekt-Lesefehler"
#, c-format
msgid "wrong object (expected: %d, read: %d)"
msgstr "Falsches Objekt (erwartet: %d, gefunden: %d)"
msgid "type read error"
msgstr "Typ-Lesefehler"
#, c-format
msgid "wrong type (expected: %d, read: %d)"
msgstr "Falscher Typ (erwartet: %d, gefunden: %d)"
msgid "%s*** Please report above info to developers ***"
msgstr ""
#, fuzzy, c-format
msgid "Error: cannot create directory \"%s\"\n"
@@ -4608,6 +4601,56 @@ msgstr "%s DCC: kann die 'nonblock'-Option für den Socket nicht festlegen\n"
msgid "%s%s: timeout for \"%s\" with %s"
msgstr "%s fehlende Argumente für die \"--dir\"-Option\n"
#, fuzzy
#~ msgid "write of infolist type 'integer'"
#~ msgstr " . Typ: Ganzzahl\n"
#, fuzzy
#~ msgid "unable to create infolist"
#~ msgstr "%s DCC: kann keine Pipe erstellen\n"
#, fuzzy
#~ msgid "unable to create infolist item"
#~ msgstr "%s DCC: kann keine Pipe erstellen\n"
#, fuzzy
#~ msgid "read of string value"
#~ msgstr " . Zeichenfolge (Werte: "
#~ msgid ""
#~ "Last operation with session file was at position %ld, read of %d bytes\n"
#~ msgstr ""
#~ "Der letzte Zugriff auf die Sitzungsdatei war bei Position %ld, %d Bytes "
#~ "gelesen.\n"
#~ msgid ""
#~ "Please send %s/%s, %s/%s and above messages to WeeChat developers for "
#~ "support.\n"
#~ "Be careful, private info may be in these files.\n"
#~ msgstr ""
#~ "Bitte senden Sie %s/%s, %s/%s und die obigen Nachrichten an die WeeChat-"
#~ "Entwickler um Support zu erhalten.\n"
#~ "Beachten Sie bitte, dass in diesen Dateien persönliche Informationen "
#~ "enthalten sein können.\n"
#~ msgid "wrong type in file (expected: %d, read: %d)"
#~ msgstr "Falscher Datentyp in der Datei (erwartet: %d, gefunden: %d)"
#~ msgid "invalid length for a buffer"
#~ msgstr "Fehlerhafte Pufferlänge"
#~ msgid "object read error"
#~ msgstr "Objekt-Lesefehler"
#~ msgid "wrong object (expected: %d, read: %d)"
#~ msgstr "Falsches Objekt (erwartet: %d, gefunden: %d)"
#~ msgid "type read error"
#~ msgstr "Typ-Lesefehler"
#~ msgid "wrong type (expected: %d, read: %d)"
#~ msgstr "Falscher Typ (erwartet: %d, gefunden: %d)"
#, fuzzy
#~ msgid "hidden"
#~ msgstr "(versteckt)"
@@ -6301,9 +6344,6 @@ msgstr "%s fehlende Argumente für die \"--dir\"-Option\n"
#~ msgid "%sDetail:\n"
#~ msgstr "%sDetail:\n"
#~ msgid " . type string (values: "
#~ msgstr " . Zeichenfolge (Werte: "
#~ msgid " . type color (Curses or Gtk color, look at WeeChat doc)\n"
#~ msgstr " . Farbe (Curses- or Gtk-color, siehe WeeChat-Dokumentation)\n"
@@ -6336,16 +6376,6 @@ msgstr "%s fehlende Argumente für die \"--dir\"-Option\n"
#~ "%s Aktualisierung nicht möglich: auf mindestens einem Server ist noch "
#~ "Anti-Flood aktiv (zu viele Zeilen gesendet)\n"
#~ msgid "Upgrading WeeChat...\n"
#~ msgstr "Aktualisiere WeeChat...\n"
#~ msgid "%s unable to save session in file\n"
#~ msgstr "%s kann die Sitzung nicht in eine Datei speichern\n"
#~ msgid "%s exec failed (program: \"%s\"), exiting WeeChat\n"
#~ msgstr ""
#~ "%s Ausführung schlug fehl (Programm: \"%s\"), WeeChat wird beendet\n"
#~ msgid "gnutls init error"
#~ msgstr "gnutls Initialisierungsfehle"
+74 -43
View File
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-07-10 17:35+0200\n"
"POT-Creation-Date: 2008-08-13 16:43+0200\n"
"PO-Revision-Date: 2007-09-19 12:09+0200\n"
"Last-Translator: Roberto González Cardenete <robert.glez@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -559,6 +559,18 @@ msgstr "no presente en el canal"
msgid "%d option(s) reset, %d option(s) removed"
msgstr ""
#, fuzzy
msgid "Upgrading WeeChat..."
msgstr "Actualizando Weechat...\n"
#, fuzzy, c-format
msgid "%sError: unable to save session in file"
msgstr "%s no ha sido posible guardar la sesión en el archivo\n"
#, fuzzy, c-format
msgid "Error: exec failed (program: \"%s\"), exiting WeeChat"
msgstr "%s exec ha fallado (programa: \"%s\"), saliendo de Weechat\n"
#, c-format
msgid "WeeChat uptime: %d %s %02d:%02d:%02d, started on %s"
msgstr "Tiempo de uso de WeeChat: %d %s %02d:%02d:%02d, empezó en %s"
@@ -1607,43 +1619,25 @@ msgid ""
"with another home using \"--dir\" command line option.\n"
msgstr ""
#, fuzzy, c-format
msgid "%sError upgrading WeeChat:"
msgstr "Actualizando Weechat...\n"
#, fuzzy, c-format
msgid "%s error: %s"
msgstr "%sServidor: %s%s\n"
#, c-format
msgid ""
"Last operation with session file was at position %ld, read of %d bytes\n"
msgid "%s last read: position: %ld, length: %d"
msgstr ""
"La última operación con el archivo de sesión fue en la posición %ld, "
"lectura de %d bytes\n"
#, c-format
msgid ""
"Please send %s/%s, %s/%s and above messages to WeeChat developers for "
"support.\n"
"Be careful, private info may be in these files.\n"
msgid "%s source: %s, line: %d"
msgstr ""
"Por favor, envía %s/%s, %s/%s y los mensajes de arriba a los desarrolladores "
"de Weechat para el soporte.\n"
"Sé cuidadoso, puede que haya información privada en estos ficheros.\n"
#, c-format
msgid "wrong type in file (expected: %d, read: %d)"
msgstr "tipo erróneo en el fichero (esperado: %d, leído: %d)"
msgid "invalid length for a buffer"
msgstr "longitud inválida para un búfer"
msgid "object read error"
msgstr "error de lectura de objeto"
#, c-format
msgid "wrong object (expected: %d, read: %d)"
msgstr "objeto erróneo (esperado: %d, leído: %d)"
msgid "type read error"
msgstr "error de lectura de tipo"
#, c-format
msgid "wrong type (expected: %d, read: %d)"
msgstr "tipo erróneo (esperado: %d, leído: %d)"
msgid "%s*** Please report above info to developers ***"
msgstr ""
#, fuzzy, c-format
msgid "Error: cannot create directory \"%s\"\n"
@@ -4615,6 +4609,55 @@ msgstr "%s no es posible crear el servidor\n"
msgid "%s%s: timeout for \"%s\" with %s"
msgstr "%s falta un argumento para la opción --dir\n"
#, fuzzy
#~ msgid "write of infolist type 'integer'"
#~ msgstr " . tipo: entero\n"
#, fuzzy
#~ msgid "unable to create infolist"
#~ msgstr "%s no es posible crear el servidor\n"
#, fuzzy
#~ msgid "unable to create infolist item"
#~ msgstr "%s no es posible crear el servidor\n"
#, fuzzy
#~ msgid "read of string value"
#~ msgstr " . tipo cadena (valores: "
#~ msgid ""
#~ "Last operation with session file was at position %ld, read of %d bytes\n"
#~ msgstr ""
#~ "La última operación con el archivo de sesión fue en la posición %ld, "
#~ "lectura de %d bytes\n"
#~ msgid ""
#~ "Please send %s/%s, %s/%s and above messages to WeeChat developers for "
#~ "support.\n"
#~ "Be careful, private info may be in these files.\n"
#~ msgstr ""
#~ "Por favor, envía %s/%s, %s/%s y los mensajes de arriba a los "
#~ "desarrolladores de Weechat para el soporte.\n"
#~ "Sé cuidadoso, puede que haya información privada en estos ficheros.\n"
#~ msgid "wrong type in file (expected: %d, read: %d)"
#~ msgstr "tipo erróneo en el fichero (esperado: %d, leído: %d)"
#~ msgid "invalid length for a buffer"
#~ msgstr "longitud inválida para un búfer"
#~ msgid "object read error"
#~ msgstr "error de lectura de objeto"
#~ msgid "wrong object (expected: %d, read: %d)"
#~ msgstr "objeto erróneo (esperado: %d, leído: %d)"
#~ msgid "type read error"
#~ msgstr "error de lectura de tipo"
#~ msgid "wrong type (expected: %d, read: %d)"
#~ msgstr "tipo erróneo (esperado: %d, leído: %d)"
#, fuzzy
#~ msgid "hidden"
#~ msgstr "(oculto)"
@@ -6316,9 +6359,6 @@ msgstr "%s falta un argumento para la opción --dir\n"
#~ msgid "%sDetail:\n"
#~ msgstr "%sDetalle:\n"
#~ msgid " . type string (values: "
#~ msgstr " . tipo cadena (valores: "
#~ msgid " . type color (Curses or Gtk color, look at WeeChat doc)\n"
#~ msgstr ""
#~ " . tipo color (color Curses o Gtk, ver la documentación de WeeChat)\n"
@@ -6350,15 +6390,6 @@ msgstr "%s falta un argumento para la opción --dir\n"
#~ msgstr ""
#~ "%s no se puede actualizar: conexión pendiente a un servidor al menos\n"
#~ msgid "Upgrading WeeChat...\n"
#~ msgstr "Actualizando Weechat...\n"
#~ msgid "%s unable to save session in file\n"
#~ msgstr "%s no ha sido posible guardar la sesión en el archivo\n"
#~ msgid "%s exec failed (program: \"%s\"), exiting WeeChat\n"
#~ msgstr "%s exec ha fallado (programa: \"%s\"), saliendo de Weechat\n"
#~ msgid "gnutls init error"
#~ msgstr "error de inicio de gnutls"
+33 -36
View File
@@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-07-10 17:35+0200\n"
"PO-Revision-Date: 2008-07-10 17:36+0200\n"
"POT-Creation-Date: 2008-08-13 16:43+0200\n"
"PO-Revision-Date: 2008-08-13 16:44+0200\n"
"Last-Translator: FlashCode <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"MIME-Version: 1.0\n"
@@ -97,7 +97,9 @@ msgstr "Liste des barres:"
msgid ""
" %s%s%s: %s%s%s (cond: %s), %s, filling: %s(top/bottom)/%s(left/right), %s: "
"%s"
msgstr " %s%s%s: %s%s%s (cond: %s), %s, remplissage: %s(haut/bas)/%s(gauche/droite), %s: %s"
msgstr ""
" %s%s%s: %s%s%s (cond: %s), %s, remplissage: %s(haut/bas)/%s(gauche/"
"droite), %s: %s"
msgid "(hidden)"
msgstr "(caché)"
@@ -518,6 +520,17 @@ msgstr "Option supprimée: %s"
msgid "%d option(s) reset, %d option(s) removed"
msgstr "%d option(s) réinitialisée(s), %d option(s) supprimée(s)"
msgid "Upgrading WeeChat..."
msgstr "Mise à jour de WeeChat..."
#, c-format
msgid "%sError: unable to save session in file"
msgstr "%sErreur: impossible de sauvegarder la session dans le ficheir"
#, c-format
msgid "Error: exec failed (program: \"%s\"), exiting WeeChat"
msgstr "Error: exec a échoué (programme: \"%s\"), sortie de WeeChat"
#, c-format
msgid "WeeChat uptime: %d %s %02d:%02d:%02d, started on %s"
msgstr "Uptime WeeChat: %d %s %02d:%02d:%02d, démarré le %s"
@@ -1609,42 +1622,24 @@ msgstr ""
"dir\".\n"
#, c-format
msgid ""
"Last operation with session file was at position %ld, read of %d bytes\n"
msgstr ""
"Dernière opération avec le fichier de session en position %ld, lecture de %d "
"octets\n"
msgid "%sError upgrading WeeChat:"
msgstr "%sErreur de mise à jour de WeeChat:"
#, c-format
msgid ""
"Please send %s/%s, %s/%s and above messages to WeeChat developers for "
"support.\n"
"Be careful, private info may be in these files.\n"
msgstr ""
"Merci d'envoyer %s/%s, %s/%s et les messages ci-dessus aux développeurs "
"WeeChat pour du support.\n"
"Faites attention, des infos privées peuvent se trouver dans ces fichiers.\n"
msgid "%s error: %s"
msgstr "%s erreur: %s"
#, c-format
msgid "wrong type in file (expected: %d, read: %d)"
msgstr "type erroné dans le fichier (attendu: %d, lu: %d)"
msgid "invalid length for a buffer"
msgstr "longueur invalide pour une zone"
msgid "object read error"
msgstr "erreur de lecture de l'objet"
msgid "%s last read: position: %ld, length: %d"
msgstr "%s dernier lu: position: %ld, longueur: %d"
#, c-format
msgid "wrong object (expected: %d, read: %d)"
msgstr "objet erroné (attendu: %d, lu: %d)"
msgid "type read error"
msgstr "erreur de lecture du type"
msgid "%s source: %s, line: %d"
msgstr "%s source: %s, ligne: %d"
#, c-format
msgid "wrong type (expected: %d, read: %d)"
msgstr "type erroné (attendu: %d, lu: %d)"
msgid "%s*** Please report above info to developers ***"
msgstr "%s*** Merci de reporter les erreurs ci-dessus aux développeurs ***"
#, c-format
msgid "Error: cannot create directory \"%s\"\n"
@@ -1710,12 +1705,17 @@ msgstr ""
msgid ""
"bar filling direction (\"horizontal\" (from left to right) or \"vertical"
"\" (from top to bottom)) when bar position is top or bottom"
msgstr "direction de remplissage de la barre (\"horizontal\" (de gauche à droite) ou \"vertical\" (de haut en bas)) quand la position de la barre est haut ou bas"
msgstr ""
"direction de remplissage de la barre (\"horizontal\" (de gauche à droite) ou "
"\"vertical\" (de haut en bas)) quand la position de la barre est haut ou bas"
msgid ""
"bar filling direction (\"horizontal\" (from left to right) or \"vertical"
"\" (from top to bottom)) when bar position is left or right"
msgstr "direction de remplissage de la barre (\"horizontal\" (de gauche à droite) ou \"vertical\" (de haut en bas)) quand la position de la barre est gauche ou droite"
msgstr ""
"direction de remplissage de la barre (\"horizontal\" (de gauche à droite) ou "
"\"vertical\" (de haut en bas)) quand la position de la barre est gauche ou "
"droite"
msgid "bar size in chars (0 = auto size)"
msgstr "taille de la barre en caractères (0 = taille automatique)"
@@ -4602,6 +4602,3 @@ msgstr "%s%s: impossible de positionner l'option \"nonblock\" pour la socket"
#, c-format
msgid "%s%s: timeout for \"%s\" with %s"
msgstr "%s%s: délai d'attente dépassé pour \"%s\" avec %s"
#~ msgid "hidden"
#~ msgstr "caché"
+68 -41
View File
@@ -12,7 +12,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-07-10 17:35+0200\n"
"POT-Creation-Date: 2008-08-13 16:43+0200\n"
"PO-Revision-Date: 2007-10-10 18:07+0200\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -565,6 +565,18 @@ msgstr "nincs a szobában"
msgid "%d option(s) reset, %d option(s) removed"
msgstr ""
#, fuzzy
msgid "Upgrading WeeChat..."
msgstr "WeeChat frissítése...\n"
#, fuzzy, c-format
msgid "%sError: unable to save session in file"
msgstr "%s nem sikerült a folyamatot menteni\n"
#, fuzzy, c-format
msgid "Error: exec failed (program: \"%s\"), exiting WeeChat"
msgstr "%s futtatási hiba (program: \"%s\"), a WeeChat kilép\n"
#, c-format
msgid "WeeChat uptime: %d %s %02d:%02d:%02d, started on %s"
msgstr "WeeChat futásidő: %d %s %02d:%02d:%02d, elindítva: %s"
@@ -1633,41 +1645,25 @@ msgstr ""
"Ha egy másik WeeChat folyamat használja ezt a fájlt, próbálja másik\n"
"saját könyvtárral futtatni a WeeChat-et a \"--dir\" opció segítségével!\n"
#, fuzzy, c-format
msgid "%sError upgrading WeeChat:"
msgstr "WeeChat frissítése...\n"
#, fuzzy, c-format
msgid "%s error: %s"
msgstr "%sSzerver: %s%s\n"
#, c-format
msgid ""
"Last operation with session file was at position %ld, read of %d bytes\n"
msgid "%s last read: position: %ld, length: %d"
msgstr ""
#, c-format
msgid ""
"Please send %s/%s, %s/%s and above messages to WeeChat developers for "
"support.\n"
"Be careful, private info may be in these files.\n"
msgid "%s source: %s, line: %d"
msgstr ""
"Kérjük küldje el a %s/%s, %s/%s és a fölötte látható üzeneteket a WeeChat "
"fejlesztőinek ha segítségre van szüksége.\n"
"Figyelem, ezek a fájlok személyes adatokat tartalmazhatnak.\n"
#, c-format
msgid "wrong type in file (expected: %d, read: %d)"
msgstr "rossz típus a fájlban (várt: %d, beolvasott: %d)"
msgid "invalid length for a buffer"
msgstr "érvénytelen pufferhossz"
msgid "object read error"
msgstr "objektumolvasási hiba"
#, c-format
msgid "wrong object (expected: %d, read: %d)"
msgstr "hibás objektum (várt: %d, beolvasott: %d)"
msgid "type read error"
msgstr "típus olvasási hiba"
#, c-format
msgid "wrong type (expected: %d, read: %d)"
msgstr "rossz típus (várt: %d, beolvasott: %d)"
msgid "%s*** Please report above info to developers ***"
msgstr ""
#, fuzzy, c-format
msgid "Error: cannot create directory \"%s\"\n"
@@ -4624,6 +4620,49 @@ msgstr "%s DCC: nem sikerült 'nonblock' opciót beállítani a csatornán\n"
msgid "%s%s: timeout for \"%s\" with %s"
msgstr "%s hiányzó argumentum a(z) \"%s\" opciónak\n"
#, fuzzy
#~ msgid "write of infolist type 'integer'"
#~ msgstr " . típus: szám\n"
#, fuzzy
#~ msgid "unable to create infolist"
#~ msgstr "%s DCC: nem sikerült a csövet létrehozni\n"
#, fuzzy
#~ msgid "unable to create infolist item"
#~ msgstr "%s DCC: nem sikerült a csövet létrehozni\n"
#, fuzzy
#~ msgid "read of string value"
#~ msgstr " . típus szöveg (értékek: "
#~ msgid ""
#~ "Please send %s/%s, %s/%s and above messages to WeeChat developers for "
#~ "support.\n"
#~ "Be careful, private info may be in these files.\n"
#~ msgstr ""
#~ "Kérjük küldje el a %s/%s, %s/%s és a fölötte látható üzeneteket a WeeChat "
#~ "fejlesztőinek ha segítségre van szüksége.\n"
#~ "Figyelem, ezek a fájlok személyes adatokat tartalmazhatnak.\n"
#~ msgid "wrong type in file (expected: %d, read: %d)"
#~ msgstr "rossz típus a fájlban (várt: %d, beolvasott: %d)"
#~ msgid "invalid length for a buffer"
#~ msgstr "érvénytelen pufferhossz"
#~ msgid "object read error"
#~ msgstr "objektumolvasási hiba"
#~ msgid "wrong object (expected: %d, read: %d)"
#~ msgstr "hibás objektum (várt: %d, beolvasott: %d)"
#~ msgid "type read error"
#~ msgstr "típus olvasási hiba"
#~ msgid "wrong type (expected: %d, read: %d)"
#~ msgstr "rossz típus (várt: %d, beolvasott: %d)"
#, fuzzy
#~ msgid "hidden"
#~ msgstr "(rejtett)"
@@ -6286,9 +6325,6 @@ msgstr "%s hiányzó argumentum a(z) \"%s\" opciónak\n"
#~ msgid "%sDetail:\n"
#~ msgstr "%sRészletek:\n"
#~ msgid " . type string (values: "
#~ msgstr " . típus szöveg (értékek: "
#~ msgid " . type color (Curses or Gtk color, look at WeeChat doc)\n"
#~ msgstr " . típus szín (Curses vagy Gtk szín, lásd WeeChat dokumentáció)\n"
@@ -6314,15 +6350,6 @@ msgstr "%s hiányzó argumentum a(z) \"%s\" opciónak\n"
#~ "%s nem sikerült frissíteni: az anti-flood (több sor küldése) legalább egy "
#~ "szerveren aktív\n"
#~ msgid "Upgrading WeeChat...\n"
#~ msgstr "WeeChat frissítése...\n"
#~ msgid "%s unable to save session in file\n"
#~ msgstr "%s nem sikerült a folyamatot menteni\n"
#~ msgid "%s exec failed (program: \"%s\"), exiting WeeChat\n"
#~ msgstr "%s futtatási hiba (program: \"%s\"), a WeeChat kilép\n"
#~ msgid "gnutls init error"
#~ msgstr "gnutls inicializációs hiba"
+73 -41
View File
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-07-10 17:35+0200\n"
"POT-Creation-Date: 2008-08-13 16:43+0200\n"
"PO-Revision-Date: 2007-09-06 12:44+0200\n"
"Last-Translator: Pavel Shevchuk <stlwrt@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -560,6 +560,18 @@ msgstr "не на канале"
msgid "%d option(s) reset, %d option(s) removed"
msgstr ""
#, fuzzy
msgid "Upgrading WeeChat..."
msgstr "Обновляю WeeChat...\n"
#, fuzzy, c-format
msgid "%sError: unable to save session in file"
msgstr "%s не могу сохранить сессию в файл\n"
#, fuzzy, c-format
msgid "Error: exec failed (program: \"%s\"), exiting WeeChat"
msgstr "%s запуск не удался (программа: \"%s\"), выхожу из WeeChat\n"
#, c-format
msgid "WeeChat uptime: %d %s %02d:%02d:%02d, started on %s"
msgstr "WeeChat работает: %d %s %02d:%02d:%02d, запущен %s"
@@ -1635,41 +1647,25 @@ msgstr ""
"WeeChat\n"
"с другой домашней директорией используя параметр \"--dir\".\n"
#, c-format
msgid ""
"Last operation with session file was at position %ld, read of %d bytes\n"
msgstr "Последняя операция с файлом сессии в позиции %ld, чтение %d байтов\n"
#, fuzzy, c-format
msgid "%sError upgrading WeeChat:"
msgstr "Обновляю WeeChat...\n"
#, fuzzy, c-format
msgid "%s error: %s"
msgstr "%sСервер: %s%s\n"
#, c-format
msgid ""
"Please send %s/%s, %s/%s and above messages to WeeChat developers for "
"support.\n"
"Be careful, private info may be in these files.\n"
msgid "%s last read: position: %ld, length: %d"
msgstr ""
"Пожалуйста, пошлите %s/%s, %s/%s и эти сообщения разработчикам WeeChat для "
"поддержки разработки.\n"
"Будьте осторожны, файлы могут содержать личные данные.\n"
#, c-format
msgid "wrong type in file (expected: %d, read: %d)"
msgstr "некорректный тип в файле (ожидалось: %d, прочитано: %d)"
msgid "invalid length for a buffer"
msgstr "некорректная длина буфера"
msgid "object read error"
msgstr "ошибка чтения объекта"
msgid "%s source: %s, line: %d"
msgstr ""
#, c-format
msgid "wrong object (expected: %d, read: %d)"
msgstr "некорректный объект (ожидалось: %d, прочитано: %d)"
msgid "type read error"
msgstr "ошибка чтения типа"
#, c-format
msgid "wrong type (expected: %d, read: %d)"
msgstr "некорректный тип (ожидалось: %d, прочитано: %d)"
msgid "%s*** Please report above info to developers ***"
msgstr ""
#, fuzzy, c-format
msgid "Error: cannot create directory \"%s\"\n"
@@ -4607,6 +4603,54 @@ msgstr "%s DCC: не могу установить неблокирующий р
msgid "%s%s: timeout for \"%s\" with %s"
msgstr "%s нет аргумента для параметра \"%s\"\n"
#, fuzzy
#~ msgid "write of infolist type 'integer'"
#~ msgstr " . тип: целочисленный\n"
#, fuzzy
#~ msgid "unable to create infolist"
#~ msgstr "%s DCC: не могу создать pipe\n"
#, fuzzy
#~ msgid "unable to create infolist item"
#~ msgstr "%s DCC: не могу создать pipe\n"
#, fuzzy
#~ msgid "read of string value"
#~ msgstr " . строковой тип (значения: "
#~ msgid ""
#~ "Last operation with session file was at position %ld, read of %d bytes\n"
#~ msgstr ""
#~ "Последняя операция с файлом сессии в позиции %ld, чтение %d байтов\n"
#~ msgid ""
#~ "Please send %s/%s, %s/%s and above messages to WeeChat developers for "
#~ "support.\n"
#~ "Be careful, private info may be in these files.\n"
#~ msgstr ""
#~ "Пожалуйста, пошлите %s/%s, %s/%s и эти сообщения разработчикам WeeChat "
#~ "для поддержки разработки.\n"
#~ "Будьте осторожны, файлы могут содержать личные данные.\n"
#~ msgid "wrong type in file (expected: %d, read: %d)"
#~ msgstr "некорректный тип в файле (ожидалось: %d, прочитано: %d)"
#~ msgid "invalid length for a buffer"
#~ msgstr "некорректная длина буфера"
#~ msgid "object read error"
#~ msgstr "ошибка чтения объекта"
#~ msgid "wrong object (expected: %d, read: %d)"
#~ msgstr "некорректный объект (ожидалось: %d, прочитано: %d)"
#~ msgid "type read error"
#~ msgstr "ошибка чтения типа"
#~ msgid "wrong type (expected: %d, read: %d)"
#~ msgstr "некорректный тип (ожидалось: %d, прочитано: %d)"
#, fuzzy
#~ msgid "hidden"
#~ msgstr "(скрытый)"
@@ -6297,9 +6341,6 @@ msgstr "%s нет аргумента для параметра \"%s\"\n"
#~ msgid "%sDetail:\n"
#~ msgstr "%sПодробности:\n"
#~ msgid " . type string (values: "
#~ msgstr " . строковой тип (значения: "
#~ msgid " . type color (Curses or Gtk color, look at WeeChat doc)\n"
#~ msgstr " . цветовой тип (цвет Curses или Gtk, см. документацию WeeChat)\n"
@@ -6328,15 +6369,6 @@ msgstr "%s нет аргумента для параметра \"%s\"\n"
#~ "%s не могу обновиться: анти-флуд не завершил работу (отсылаются несколько "
#~ "строк)\n"
#~ msgid "Upgrading WeeChat...\n"
#~ msgstr "Обновляю WeeChat...\n"
#~ msgid "%s unable to save session in file\n"
#~ msgstr "%s не могу сохранить сессию в файл\n"
#~ msgid "%s exec failed (program: \"%s\"), exiting WeeChat\n"
#~ msgstr "%s запуск не удался (программа: \"%s\"), выхожу из WeeChat\n"
#~ msgid "gnutls init error"
#~ msgstr "ошибка инициализации gnutls"
+6 -2
View File
@@ -13,6 +13,8 @@ SET(WEECHAT_SOURCES
./src/core/wee-debug.h
./src/core/wee-hook.c
./src/core/wee-hook.h
./src/core/wee-infolist.c
./src/core/wee-infolist.h
./src/core/wee-input.c
./src/core/wee-input.h
./src/core/wee-list.c
@@ -25,6 +27,8 @@ SET(WEECHAT_SOURCES
./src/core/wee-string.h
./src/core/wee-upgrade.c
./src/core/wee-upgrade.h
./src/core/wee-upgrade-file.c
./src/core/wee-upgrade-file.h
./src/core/wee-utf8.c
./src/core/wee-utf8.h
./src/core/wee-util.c
@@ -131,8 +135,6 @@ SET(WEECHAT_SOURCES
./src/plugins/plugin-config.c
./src/plugins/plugin-config.h
./src/plugins/plugin.h
./src/plugins/plugin-infolist.c
./src/plugins/plugin-infolist.h
./src/plugins/scripts/lua/weechat-lua-api.c
./src/plugins/scripts/lua/weechat-lua-api.h
./src/plugins/scripts/lua/weechat-lua.c
@@ -179,4 +181,6 @@ SET(WEECHAT_SOURCES
./src/plugins/xfer/xfer.h
./src/plugins/xfer/xfer-network.c
./src/plugins/xfer/xfer-network.h
./src/plugins/xfer/xfer-upgrade.c
./src/plugins/xfer/xfer-upgrade.h
)
+17 -19
View File
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-07-10 17:35+0200\n"
"POT-Creation-Date: 2008-08-13 16:43+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -495,6 +495,17 @@ msgstr ""
msgid "%d option(s) reset, %d option(s) removed"
msgstr ""
msgid "Upgrading WeeChat..."
msgstr ""
#, c-format
msgid "%sError: unable to save session in file"
msgstr ""
#, c-format
msgid "Error: exec failed (program: \"%s\"), exiting WeeChat"
msgstr ""
#, c-format
msgid "WeeChat uptime: %d %s %02d:%02d:%02d, started on %s"
msgstr ""
@@ -1350,36 +1361,23 @@ msgid ""
msgstr ""
#, c-format
msgid ""
"Last operation with session file was at position %ld, read of %d bytes\n"
msgid "%sError upgrading WeeChat:"
msgstr ""
#, c-format
msgid ""
"Please send %s/%s, %s/%s and above messages to WeeChat developers for "
"support.\n"
"Be careful, private info may be in these files.\n"
msgid "%s error: %s"
msgstr ""
#, c-format
msgid "wrong type in file (expected: %d, read: %d)"
msgstr ""
msgid "invalid length for a buffer"
msgstr ""
msgid "object read error"
msgid "%s last read: position: %ld, length: %d"
msgstr ""
#, c-format
msgid "wrong object (expected: %d, read: %d)"
msgstr ""
msgid "type read error"
msgid "%s source: %s, line: %d"
msgstr ""
#, c-format
msgid "wrong type (expected: %d, read: %d)"
msgid "%s*** Please report above info to developers ***"
msgstr ""
#, c-format
+2
View File
@@ -22,12 +22,14 @@ wee-config.c wee-config.h
wee-config-file.c wee-config-file.h
wee-debug.c wee-debug.h
wee-hook.c wee-hook.h
wee-infolist.c wee-infolist.h
wee-input.c wee-input.h
wee-list.c wee-list.h
wee-log.c wee-log.h
wee-network.c wee-network.h
wee-string.c wee-string.h
wee-upgrade.c wee-upgrade.h
wee-upgrade-file.c wee-upgrade-file.h
wee-utf8.c wee-utf8.h
wee-util.c wee-util.h)
+4
View File
@@ -32,6 +32,8 @@ lib_weechat_core_a_SOURCES = weechat.c \
wee-debug.h \
wee-hook.c \
wee-hook.h \
wee-infolist.c \
wee-infolist.h \
wee-input.c \
wee-input.h \
wee-list.c \
@@ -42,6 +44,8 @@ lib_weechat_core_a_SOURCES = weechat.c \
wee-network.h \
wee-upgrade.c \
wee-upgrade.h \
wee-upgrade-file.c \
wee-upgrade-file.h \
wee-string.c \
wee-string.h \
wee-utf8.c \
+20 -59
View File
@@ -51,6 +51,7 @@
#include "../gui/gui-hotlist.h"
#include "../gui/gui-input.h"
#include "../gui/gui-keyboard.h"
#include "../gui/gui-main.h"
#include "../gui/gui-status.h"
#include "../gui/gui-window.h"
#include "../plugins/plugin.h"
@@ -2283,9 +2284,8 @@ int
command_upgrade (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
/*int filename_length;
char *filename, *ptr_binary;
char *exec_args[7] = { NULL, "-a", "--dir", NULL, "--session", NULL, NULL };*/
char *ptr_binary;
char *exec_args[7] = { NULL, "-a", "--dir", NULL, "--upgrade", NULL };
/* make C compiler happy */
(void) data;
@@ -2293,85 +2293,46 @@ command_upgrade (void *data, struct t_gui_buffer *buffer,
(void) argc;
(void) argv;
(void) argv_eol;
/* TODO: enable again /upgrade command */
gui_chat_printf (NULL, "/upgrade command is temporarirly disabled.");
return WEECHAT_RC_OK;
/*ptr_binary = (argc > 1) ? argv_eol[1] : weechat_argv0;
ptr_binary = (argc > 1) ? argv_eol[1] : weechat_argv0;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
gui_chat_printf (NULL,
_("Upgrading WeeChat..."));
/* send "upgrade" signal to plugins */
hook_signal_send ("upgrade", WEECHAT_HOOK_SIGNAL_STRING, NULL);
if (!upgrade_weechat_save ())
{
if (ptr_server->child_pid != 0)
{
gui_chat_printf_error (NULL,
_("Error: can't upgrade: connection to at least "
"one server is pending"));
return WEECHAT_RC_ERROR;
}*/
/* TODO: remove this test, and fix gnutls save/load in session */
/*if (ptr_server->is_connected && ptr_server->ssl_connected)
{
gui_chat_printf_error_nolog (NULL,
_("Error: can't upgrade: connection to at least "
"one SSL server is active "
"(should be fixed in a future version)"));
return WEECHAT_RC_ERROR;
}
if (ptr_server->outqueue)
{
gui_chat_printf_error_nolog (NULL,
_("Error: can't upgrade: anti-flood is active on "
"at least one server (sending many lines)"));
return WEECHAT_RC_ERROR;
}
}
filename_length = strlen (weechat_home) + strlen (WEECHAT_SESSION_NAME) + 2;
filename = malloc (filename_length);
if (!filename)
return -2;
snprintf (filename, filename_length, "%s%s" WEECHAT_SESSION_NAME,
weechat_home, DIR_SEPARATOR);
gui_chat_printf_info_nolog (NULL,
_("Upgrading WeeChat..."));
if (!session_save (filename))
{
free (filename);
gui_chat_printf_error_nolog (NULL,
_("Error: unable to save session in file"));
gui_chat_printf (NULL,
_("%sError: unable to save session in file"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
return WEECHAT_RC_ERROR;
}
exec_args[0] = strdup (ptr_binary);
exec_args[3] = strdup (weechat_home);
exec_args[5] = strdup (filename);*/
/* unload plugins, save config, then upgrade */
plugin_end ();
/*if (CONFIG_BOOLEAN(config_look_save_on_exit))
(void) config_write (NULL);
if (CONFIG_BOOLEAN(config_look_save_on_exit))
(void) config_weechat_write ();
gui_main_end (1);
fifo_remove ();
weechat_log_close ();
log_close ();
execvp (exec_args[0], exec_args);*/
execvp (exec_args[0], exec_args);
/* this code should not be reached if execvp is ok */
plugin_init (1, 0, NULL);
/*string_iconv_fprintf (stderr,
string_iconv_fprintf (stderr,
_("Error: exec failed (program: \"%s\"), exiting WeeChat"),
exec_args[0]);
free (exec_args[0]);
free (exec_args[3]);
free (filename);
exit (EXIT_FAILURE);*/
exit (EXIT_FAILURE);
/* never executed */
return WEECHAT_RC_ERROR;
+201
View File
@@ -33,6 +33,7 @@
#include "weechat.h"
#include "wee-config-file.h"
#include "wee-hook.h"
#include "wee-infolist.h"
#include "wee-log.h"
#include "wee-string.h"
#include "../gui/gui-color.h"
@@ -2104,6 +2105,206 @@ config_file_free_all_plugin (struct t_weechat_plugin *plugin)
}
}
/*
* config_file_add_to_infolist: add config options in an infolist
* return 1 if ok, 0 if error
*/
int
config_file_add_to_infolist (struct t_infolist *infolist,
const char *option_name)
{
struct t_config_file *ptr_config;
struct t_config_section *ptr_section;
struct t_config_option *ptr_option;
struct t_infolist_item *ptr_item;
int length;
char *option_full_name, value[128];
if (!infolist)
return 0;
for (ptr_config = config_files; ptr_config;
ptr_config = ptr_config->next_config)
{
for (ptr_section = ptr_config->sections; ptr_section;
ptr_section = ptr_section->next_section)
{
for (ptr_option = ptr_section->options; ptr_option;
ptr_option = ptr_option->next_option)
{
length = strlen (ptr_config->name) + 1 +
strlen (ptr_section->name) + 1 +
strlen (ptr_option->name) + 1;
option_full_name = malloc (length);
if (option_full_name)
{
snprintf (option_full_name, length, "%s.%s.%s",
ptr_config->name,
ptr_section->name,
ptr_option->name);
if (!option_name || !option_name[0]
|| string_match (option_full_name, option_name, 0))
{
ptr_item = infolist_new_item (infolist);
if (!ptr_item)
{
free (option_full_name);
return 0;
}
if (!infolist_new_var_string (ptr_item,
"full_name",
option_full_name))
{
free (option_full_name);
return 0;
}
if (!infolist_new_var_string (ptr_item,
"name",
ptr_option->name))
{
free (option_full_name);
return 0;
}
switch (ptr_option->type)
{
case CONFIG_OPTION_TYPE_BOOLEAN:
if (!infolist_new_var_string (ptr_item,
"type",
"boolean"))
{
free (option_full_name);
return 0;
}
if (CONFIG_BOOLEAN(ptr_option) == CONFIG_BOOLEAN_TRUE)
snprintf (value, sizeof (value), "on");
else
snprintf (value, sizeof (value), "off");
if (!infolist_new_var_string (ptr_item,
"value",
value))
{
free (option_full_name);
return 0;
}
if (CONFIG_BOOLEAN_DEFAULT(ptr_option) == CONFIG_BOOLEAN_TRUE)
snprintf (value, sizeof (value), "on");
else
snprintf (value, sizeof (value), "off");
if (!infolist_new_var_string (ptr_item,
"default_value",
value))
{
free (option_full_name);
return 0;
}
break;
case CONFIG_OPTION_TYPE_INTEGER:
if (!infolist_new_var_string (ptr_item,
"type",
"integer"))
{
free (option_full_name);
return 0;
}
if (ptr_option->string_values)
{
if (!infolist_new_var_string (ptr_item,
"value",
ptr_option->string_values[CONFIG_INTEGER(ptr_option)]))
{
free (option_full_name);
return 0;
}
if (!infolist_new_var_string (ptr_item,
"default_value",
ptr_option->string_values[CONFIG_INTEGER_DEFAULT(ptr_option)]))
{
free (option_full_name);
return 0;
}
}
else
{
snprintf (value, sizeof (value), "%d",
CONFIG_INTEGER(ptr_option));
if (!infolist_new_var_string (ptr_item,
"value",
value))
{
free (option_full_name);
return 0;
}
snprintf (value, sizeof (value), "%d",
CONFIG_INTEGER_DEFAULT(ptr_option));
if (!infolist_new_var_string (ptr_item,
"default_value",
value))
{
free (option_full_name);
return 0;
}
}
break;
case CONFIG_OPTION_TYPE_STRING:
if (!infolist_new_var_string (ptr_item,
"type",
"string"))
{
free (option_full_name);
return 0;
}
if (!infolist_new_var_string (ptr_item,
"value",
CONFIG_STRING(ptr_option)))
{
free (option_full_name);
return 0;
}
if (!infolist_new_var_string (ptr_item,
"default_value",
CONFIG_STRING_DEFAULT(ptr_option)))
{
free (option_full_name);
return 0;
}
break;
case CONFIG_OPTION_TYPE_COLOR:
if (!infolist_new_var_string (ptr_item,
"type",
"color"))
{
free (option_full_name);
return 0;
}
if (!infolist_new_var_string (ptr_item,
"value",
gui_color_get_name (CONFIG_COLOR(ptr_option))))
{
free (option_full_name);
return 0;
}
if (!infolist_new_var_string (ptr_item,
"default_value",
gui_color_get_name (CONFIG_COLOR_DEFAULT(ptr_option))))
{
free (option_full_name);
return 0;
}
break;
case CONFIG_NUM_OPTION_TYPES:
break;
}
}
free (option_full_name);
}
}
}
}
return 1;
}
/*
* config_file_print_stdout: print options on standard output
*/
+3
View File
@@ -36,6 +36,7 @@
#define CONFIG_BOOLEAN_TRUE 1
struct t_weelist;
struct t_infolist;
struct t_config_file
{
@@ -228,6 +229,8 @@ extern void config_file_section_free (struct t_config_file *config_file,
extern void config_file_free (struct t_config_file *config_file);
extern void config_file_free_all ();
extern void config_file_free_all_plugin (struct t_weechat_plugin *plugin);
extern int config_file_add_to_infolist (struct t_infolist *infolist,
const char *option_name);
extern void config_file_print_stdout (struct t_config_file *config_file);
extern void config_file_print_log ();
+3
View File
@@ -28,6 +28,7 @@
#include "weechat.h"
#include "wee-backtrace.h"
#include "wee-config-file.h"
#include "wee-infolist.h"
#include "wee-log.h"
#include "wee-hook.h"
#include "wee-string.h"
@@ -83,6 +84,8 @@ debug_dump (int crash)
gui_bar_item_print_log ();
gui_hotlist_print_log ();
infolist_print_log ();
hook_print_log ();
config_file_print_log ();
+708
View File
@@ -0,0 +1,708 @@
/*
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
/* wee-infolist.c: manages info lists */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include "weechat.h"
#include "wee-log.h"
#include "wee-string.h"
#include "wee-infolist.h"
struct t_infolist *weechat_infolists = NULL;
struct t_infolist *last_weechat_infolist = NULL;
/*
* infolist_new: create a new weechat infolist
*/
struct t_infolist *
infolist_new ()
{
struct t_infolist *new_infolist;
new_infolist = malloc (sizeof (*new_infolist));
if (new_infolist)
{
new_infolist->items = NULL;
new_infolist->last_item = NULL;
new_infolist->ptr_item = NULL;
new_infolist->prev_infolist = last_weechat_infolist;
new_infolist->next_infolist = NULL;
if (weechat_infolists)
last_weechat_infolist->next_infolist = new_infolist;
else
weechat_infolists = new_infolist;
last_weechat_infolist = new_infolist;
}
return new_infolist;
}
/*
* infolist_new_item: create a new item in an infolist
*/
struct t_infolist_item *
infolist_new_item (struct t_infolist *infolist)
{
struct t_infolist_item *new_item;
new_item = malloc (sizeof (*new_item));
if (new_item)
{
new_item->vars = NULL;
new_item->last_var = NULL;
new_item->fields = NULL;
new_item->prev_item = infolist->last_item;
new_item->next_item = NULL;
if (infolist->items)
infolist->last_item->next_item = new_item;
else
infolist->items = new_item;
infolist->last_item = new_item;
}
return new_item;
}
/*
* infolist_new_var_integer: create a new integer variable in an item
*/
struct t_infolist_var *
infolist_new_var_integer (struct t_infolist_item *item,
const char *name, int value)
{
struct t_infolist_var *new_var;
if (!item || !name || !name[0])
return NULL;
new_var = malloc (sizeof (*new_var));
if (new_var)
{
new_var->name = strdup (name);
new_var->type = INFOLIST_INTEGER;
new_var->value = malloc (sizeof (int));
if (new_var->value)
*((int *)new_var->value) = value;
new_var->prev_var = item->last_var;
new_var->next_var = NULL;
if (item->vars)
item->last_var->next_var = new_var;
else
item->vars = new_var;
item->last_var = new_var;
}
return new_var;
}
/*
* infolist_new_var_string: create a new string variable in an item
*/
struct t_infolist_var *
infolist_new_var_string (struct t_infolist_item *item,
const char *name, const char *value)
{
struct t_infolist_var *new_var;
if (!item || !name || !name[0])
return NULL;
new_var = malloc (sizeof (*new_var));
if (new_var)
{
new_var->name = strdup (name);
new_var->type = INFOLIST_STRING;
new_var->value = (value) ? strdup (value) : NULL;
new_var->prev_var = item->last_var;
new_var->next_var = NULL;
if (item->vars)
item->last_var->next_var = new_var;
else
item->vars = new_var;
item->last_var = new_var;
}
return new_var;
}
/*
* infolist_new_var_pointer: create a new pointer variable in an item
*/
struct t_infolist_var *
infolist_new_var_pointer (struct t_infolist_item *item,
const char *name, void *pointer)
{
struct t_infolist_var *new_var;
if (!item || !name || !name[0])
return NULL;
new_var = malloc (sizeof (*new_var));
if (new_var)
{
new_var->name = strdup (name);
new_var->type = INFOLIST_POINTER;
new_var->value = pointer;
new_var->prev_var = item->last_var;
new_var->next_var = NULL;
if (item->vars)
item->last_var->next_var = new_var;
else
item->vars = new_var;
item->last_var = new_var;
}
return new_var;
}
/*
* infolist_new_var_buffer: create a new buffer variable in an item
*/
struct t_infolist_var *
infolist_new_var_buffer (struct t_infolist_item *item,
const char *name, void *pointer, int size)
{
struct t_infolist_var *new_var;
if (!item || !name || !name[0] || (size <= 0))
return NULL;
new_var = malloc (sizeof (*new_var));
if (new_var)
{
new_var->name = strdup (name);
new_var->type = INFOLIST_BUFFER;
new_var->value = malloc (size);
if (new_var->value)
memcpy (new_var->value, pointer, size);
new_var->size = size;
new_var->prev_var = item->last_var;
new_var->next_var = NULL;
if (item->vars)
item->last_var->next_var = new_var;
else
item->vars = new_var;
item->last_var = new_var;
}
return new_var;
}
/*
* infolist_new_var_time: create a new time variable in an item
*/
struct t_infolist_var *
infolist_new_var_time (struct t_infolist_item *item,
const char *name, time_t time)
{
struct t_infolist_var *new_var;
if (!item || !name || !name[0])
return NULL;
new_var = malloc (sizeof (*new_var));
if (new_var)
{
new_var->name = strdup (name);
new_var->type = INFOLIST_TIME;
new_var->value = malloc (sizeof (time_t));
if (new_var->value)
*((time_t *)new_var->value) = time;
new_var->prev_var = item->last_var;
new_var->next_var = NULL;
if (item->vars)
item->last_var->next_var = new_var;
else
item->vars = new_var;
item->last_var = new_var;
}
return new_var;
}
/*
* infolist_valid: check if an infolist pointer exists
* return 1 if list exists
* 0 if list is not found
*/
int
infolist_valid (struct t_infolist *infolist)
{
struct t_infolist *ptr_infolist;
for (ptr_infolist = weechat_infolists; ptr_infolist;
ptr_infolist = ptr_infolist->next_infolist)
{
if (ptr_infolist == infolist)
return 1;
}
/* list not found */
return 0;
}
/*
* infolist_next: return next item for an infolist
* if current item pointer is NULL,
* then return first item of infolist
*/
struct t_infolist_item *
infolist_next (struct t_infolist *infolist)
{
if (!infolist->ptr_item)
{
infolist->ptr_item = infolist->items;
return infolist->ptr_item;
}
infolist->ptr_item = infolist->ptr_item->next_item;
return infolist->ptr_item;
}
/*
* infolist_prev: return previous item for an infolist
* if current item pointer is NULL,
* then return last item of infolist
*/
struct t_infolist_item *
infolist_prev (struct t_infolist *infolist)
{
if (!infolist->ptr_item)
{
infolist->ptr_item = infolist->last_item;
return infolist->ptr_item;
}
infolist->ptr_item = infolist->ptr_item->prev_item;
return infolist->ptr_item;
}
/*
* infolist_reset_item_cursor: reset pointer to current item in infolist
*/
void
infolist_reset_item_cursor (struct t_infolist *infolist)
{
infolist->ptr_item = NULL;
}
/*
* infolist_fields: get list of fields for current infolist item
*/
char *
infolist_fields (struct t_infolist *infolist)
{
struct t_infolist_var *ptr_var;
int length;
if (!infolist || !infolist->ptr_item)
return NULL;
/* list of fields already asked ? if yes, just return string */
if (infolist->ptr_item->fields)
return infolist->ptr_item->fields;
length = 0;
for (ptr_var = infolist->ptr_item->vars;
ptr_var; ptr_var = ptr_var->next_var)
{
length += strlen (ptr_var->name) + 3;
}
infolist->ptr_item->fields = malloc (length + 1);
if (!infolist->ptr_item->fields)
return NULL;
infolist->ptr_item->fields[0] = '\0';
for (ptr_var = infolist->ptr_item->vars; ptr_var;
ptr_var = ptr_var->next_var)
{
switch (ptr_var->type)
{
case INFOLIST_INTEGER:
strcat (infolist->ptr_item->fields, "i:");
break;
case INFOLIST_STRING:
strcat (infolist->ptr_item->fields, "s:");
break;
case INFOLIST_POINTER:
strcat (infolist->ptr_item->fields, "p:");
break;
case INFOLIST_BUFFER:
strcat (infolist->ptr_item->fields, "b:");
break;
case INFOLIST_TIME:
strcat (infolist->ptr_item->fields, "t:");
break;
}
strcat (infolist->ptr_item->fields, ptr_var->name);
if (ptr_var->next_var)
strcat (infolist->ptr_item->fields, ",");
}
return infolist->ptr_item->fields;
}
/*
* infolist_integer: get an integer variable value in current infolist item
*/
int
infolist_integer (struct t_infolist *infolist, const char *var)
{
struct t_infolist_var *ptr_var;
if (!infolist || !infolist->ptr_item || !var || !var[0])
return 0;
for (ptr_var = infolist->ptr_item->vars; ptr_var;
ptr_var = ptr_var->next_var)
{
if (string_strcasecmp (ptr_var->name, var) == 0)
{
if (ptr_var->type == INFOLIST_INTEGER)
return *((int *)ptr_var->value);
else
return 0;
}
}
/* variable not found */
return 0;
}
/*
* infolist_string: get a string variable value in current list item
*/
char *
infolist_string (struct t_infolist *infolist, const char *var)
{
struct t_infolist_var *ptr_var;
if (!infolist || !infolist->ptr_item || !var || !var[0])
return NULL;
for (ptr_var = infolist->ptr_item->vars; ptr_var;
ptr_var = ptr_var->next_var)
{
if (string_strcasecmp (ptr_var->name, var) == 0)
{
if (ptr_var->type == INFOLIST_STRING)
return (char *)ptr_var->value;
else
return NULL;
}
}
/* variable not found */
return NULL;
}
/*
* infolist_pointer: get a pointer variable value in current infolist item
*/
void *
infolist_pointer (struct t_infolist *infolist, const char *var)
{
struct t_infolist_var *ptr_var;
if (!infolist || !infolist->ptr_item || !var || !var[0])
return NULL;
for (ptr_var = infolist->ptr_item->vars; ptr_var;
ptr_var = ptr_var->next_var)
{
if (string_strcasecmp (ptr_var->name, var) == 0)
{
if (ptr_var->type == INFOLIST_POINTER)
return ptr_var->value;
else
return NULL;
}
}
/* variable not found */
return NULL;
}
/*
* infolist_buffer: get a buffer variable value in current infolist item
* size is used to return size of buffer
*/
void *
infolist_buffer (struct t_infolist *infolist, const char *var,
int *size)
{
struct t_infolist_var *ptr_var;
if (!infolist || !infolist->ptr_item || !var || !var[0])
return NULL;
for (ptr_var = infolist->ptr_item->vars; ptr_var;
ptr_var = ptr_var->next_var)
{
if (string_strcasecmp (ptr_var->name, var) == 0)
{
if (ptr_var->type == INFOLIST_BUFFER)
{
*size = ptr_var->size;
return ptr_var->value;
}
else
return NULL;
}
}
/* variable not found */
return NULL;
}
/*
* infolist_time: get a time variable value in current infolist item
*/
time_t
infolist_time (struct t_infolist *infolist, const char *var)
{
struct t_infolist_var *ptr_var;
if (!infolist || !infolist->ptr_item || !var || !var[0])
return 0;
for (ptr_var = infolist->ptr_item->vars; ptr_var;
ptr_var = ptr_var->next_var)
{
if (string_strcasecmp (ptr_var->name, var) == 0)
{
if (ptr_var->type == INFOLIST_TIME)
return *((time_t *)ptr_var->value);
else
return 0;
}
}
/* variable not found */
return 0;
}
/*
* infolist_var_free: free an infolist variable
*/
void
infolist_var_free (struct t_infolist_item *item,
struct t_infolist_var *var)
{
struct t_infolist_var *new_vars;
/* remove var */
if (item->last_var == var)
item->last_var = var->prev_var;
if (var->prev_var)
{
(var->prev_var)->next_var = var->next_var;
new_vars = item->vars;
}
else
new_vars = var->next_var;
if (var->next_var)
(var->next_var)->prev_var = var->prev_var;
/* free data */
if (var->name)
free (var->name);
if (((var->type == INFOLIST_INTEGER)
|| (var->type == INFOLIST_STRING)
|| (var->type == INFOLIST_BUFFER)
|| (var->type == INFOLIST_TIME))
&& var->value)
{
free (var->value);
}
free (var);
item->vars = new_vars;
}
/*
* infolist_item_free: free an infolist item
*/
void
infolist_item_free (struct t_infolist *infolist,
struct t_infolist_item *item)
{
struct t_infolist_item *new_items;
/* remove var */
if (infolist->last_item == item)
infolist->last_item = item->prev_item;
if (item->prev_item)
{
(item->prev_item)->next_item = item->next_item;
new_items = infolist->items;
}
else
new_items = item->next_item;
if (item->next_item)
(item->next_item)->prev_item = item->prev_item;
/* free data */
while (item->vars)
{
infolist_var_free (item, item->vars);
}
if (item->fields)
free (item->fields);
free (item);
infolist->items = new_items;
}
/*
* infolist_free: free an infolist
*/
void
infolist_free (struct t_infolist *infolist)
{
struct t_infolist *new_weechat_infolists;
/* remove list */
if (last_weechat_infolist == infolist)
last_weechat_infolist = infolist->prev_infolist;
if (infolist->prev_infolist)
{
(infolist->prev_infolist)->next_infolist = infolist->next_infolist;
new_weechat_infolists = weechat_infolists;
}
else
new_weechat_infolists = infolist->next_infolist;
if (infolist->next_infolist)
(infolist->next_infolist)->prev_infolist = infolist->prev_infolist;
/* free data */
while (infolist->items)
{
infolist_item_free (infolist, infolist->items);
}
free (infolist);
weechat_infolists = new_weechat_infolists;
}
/*
* infolist_print_log: print infolists infos in log (usually for crash dump)
*/
void
infolist_print_log ()
{
struct t_infolist *ptr_infolist;
struct t_infolist_item *ptr_item;
struct t_infolist_var *ptr_var;
for (ptr_infolist = weechat_infolists; ptr_infolist;
ptr_infolist = ptr_infolist->next_infolist)
{
log_printf ("");
log_printf ("[infolist (addr:0x%x)]", ptr_infolist);
log_printf (" items. . . . . . . . . : 0x%x", ptr_infolist->items);
log_printf (" last_item. . . . . . . : 0x%x", ptr_infolist->last_item);
log_printf (" ptr_item . . . . . . . : 0x%x", ptr_infolist->ptr_item);
log_printf (" prev_infolist. . . . . : 0x%x", ptr_infolist->prev_infolist);
log_printf (" next_infolist. . . . . : 0x%x", ptr_infolist->next_infolist);
for (ptr_item = ptr_infolist->items; ptr_item;
ptr_item = ptr_item->next_item)
{
log_printf ("");
log_printf (" [item (addr:0x%x)]", ptr_item);
log_printf (" vars . . . . . . . . . : 0x%x", ptr_item->vars);
log_printf (" last_var . . . . . . . : 0x%x", ptr_item->last_var);
log_printf (" prev_item. . . . . . . : 0x%x", ptr_item->prev_item);
log_printf (" next_item. . . . . . . : 0x%x", ptr_item->next_item);
for (ptr_var = ptr_item->vars; ptr_var;
ptr_var = ptr_var->next_var)
{
log_printf ("");
log_printf (" [var (addr:0x%x)]", ptr_var);
log_printf (" name . . . . . . . . : '%s'", ptr_var->name);
log_printf (" type . . . . . . . . : %d", ptr_var->type);
switch (ptr_var->type)
{
case INFOLIST_INTEGER:
log_printf (" value (integer). . . : %d", *((int *)ptr_var->value));
break;
case INFOLIST_STRING:
log_printf (" value (string) . . . : '%s'", (char *)ptr_var->value);
break;
case INFOLIST_POINTER:
log_printf (" value (pointer). . . : 0x%x", ptr_var->value);
break;
case INFOLIST_BUFFER:
log_printf (" value (buffer) . . . : 0x%x", ptr_var->value);
log_printf (" size of buffer . . . : %d", ptr_var->size);
break;
case INFOLIST_TIME:
log_printf (" value (time) . . . . : %ld", *((time_t *)ptr_var->value));
break;
}
log_printf (" prev_var . . . . . . : 0x%x", ptr_var->prev_var);
log_printf (" next_var . . . . . . : 0x%x", ptr_var->next_var);
}
}
}
}
+105
View File
@@ -0,0 +1,105 @@
/*
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WEECHAT_INFOLIST_H
#define __WEECHAT_INFOLIST_H 1
/* list structures */
enum t_infolist_type
{
INFOLIST_INTEGER = 0,
INFOLIST_STRING,
INFOLIST_POINTER,
INFOLIST_BUFFER,
INFOLIST_TIME,
};
struct t_infolist_var
{
char *name; /* variable name */
enum t_infolist_type type; /* type: int, string, ... */
void *value; /* pointer to value */
int size; /* for type buffer */
struct t_infolist_var *prev_var; /* link to previous variable */
struct t_infolist_var *next_var; /* link to next variable */
};
struct t_infolist_item
{
struct t_infolist_var *vars; /* item variables */
struct t_infolist_var *last_var; /* last variable */
char *fields; /* fields list (NULL if never asked) */
struct t_infolist_item *prev_item; /* link to previous item */
struct t_infolist_item *next_item; /* link to next item */
};
struct t_infolist
{
struct t_infolist_item *items; /* link to items */
struct t_infolist_item *last_item; /* last variable */
struct t_infolist_item *ptr_item; /* pointer to current item */
struct t_infolist *prev_infolist; /* link to previous list */
struct t_infolist *next_infolist; /* link to next list */
};
/* list variables */
extern struct t_infolist *weechat_infolists;
extern struct t_infolist *last_weechat_infolist;
/* list functions */
extern struct t_infolist *infolist_new ();
extern struct t_infolist_item *infolist_new_item (struct t_infolist *infolist);
extern struct t_infolist_var *infolist_new_var_integer (struct t_infolist_item *item,
const char *name,
int value);
extern struct t_infolist_var *infolist_new_var_string (struct t_infolist_item *item,
const char *name,
const char *value);
extern struct t_infolist_var *infolist_new_var_pointer (struct t_infolist_item *item,
const char *name,
void *pointer);
extern struct t_infolist_var *infolist_new_var_buffer (struct t_infolist_item *item,
const char *name,
void *pointer,
int size);
extern struct t_infolist_var *infolist_new_var_time (struct t_infolist_item *item,
const char *name,
time_t time);
extern int infolist_valid (struct t_infolist *infolist);
extern struct t_infolist_item *infolist_next (struct t_infolist *infolist);
extern struct t_infolist_item *infolist_prev (struct t_infolist *infolist);
extern void infolist_reset_item_cursor (struct t_infolist *infolist);
extern char *infolist_fields (struct t_infolist *infolist);
extern int infolist_integer (struct t_infolist *infolist,
const char *var);
extern char *infolist_string (struct t_infolist *infolist,
const char *var);
extern void *infolist_pointer (struct t_infolist *infolist,
const char *var);
extern void *infolist_buffer (struct t_infolist *infolist,
const char *var, int *size);
extern time_t infolist_time (struct t_infolist *infolist,
const char *var);
extern void infolist_free (struct t_infolist *infolist);
extern void infolist_print_log ();
#endif /* wee-infolist.h */
+715
View File
@@ -0,0 +1,715 @@
/*
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
/* wee-upgrade-file.c: save/restore data for upgrading WeeChat */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "weechat.h"
#include "wee-upgrade-file.h"
#include "wee-infolist.h"
#include "wee-string.h"
#include "wee-utf8.h"
#include "../gui/gui-chat.h"
#include "../gui/gui-main.h"
#include "../plugins/plugin.h"
struct t_upgrade_file *upgrade_files = NULL;
struct t_upgrade_file *last_upgrade_file = NULL;
/*
* upgrade_file_error: display error
*/
void
upgrade_file_error (struct t_upgrade_file *upgrade_file, char *message,
char *file, int line)
{
gui_chat_printf (NULL,
_("%sError upgrading WeeChat:"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
message, file, line);
gui_chat_printf (NULL,
_("%s error: %s"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
message);
if ((upgrade_file->last_read_pos > 0)
|| (upgrade_file->last_read_length > 0))
{
gui_chat_printf (NULL,
_("%s last read: position: %ld, length: %d"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
upgrade_file->last_read_pos,
upgrade_file->last_read_length);
}
gui_chat_printf (NULL,
_("%s source: %s, line: %d"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
file, line);
gui_chat_printf (NULL,
_("%s*** Please report above info to developers ***"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
}
/*
* upgrade_file_write_integer: write int value in upgrade file
* return 1 if ok, 0 if error
*/
int
upgrade_file_write_integer (struct t_upgrade_file *upgrade_file, int value)
{
if (fwrite ((void *)(&value), sizeof (value), 1, upgrade_file->file) <= 0)
return 0;
return 1;
}
/*
* upgrade_file_write_time: write int value in upgrade file
* return 1 if ok, 0 if error
*/
int
upgrade_file_write_time (struct t_upgrade_file *upgrade_file, time_t date)
{
if (fwrite ((void *)(&date), sizeof (date), 1, upgrade_file->file) <= 0)
return 0;
return 1;
}
/*
* upgrade_file_write_string: write string in upgrade file
* return 1 if ok, 0 if error
*/
int
upgrade_file_write_string (struct t_upgrade_file *upgrade_file, char *string)
{
int length;
if (string && string[0])
{
length = strlen (string);
if (!upgrade_file_write_integer (upgrade_file, length))
return 0;
if (fwrite ((void *)string, length, 1, upgrade_file->file) <= 0)
return 0;
}
else
{
if (!upgrade_file_write_integer (upgrade_file, 0))
return 0;
}
return 1;
}
/*
* upgrade_file_write_buffer: write buffer in upgrade file
* return 1 if ok, 0 if error
*/
int
upgrade_file_write_buffer (struct t_upgrade_file *upgrade_file, void *pointer,
int size)
{
if (pointer)
{
if (!upgrade_file_write_integer (upgrade_file, size))
return 0;
if (fwrite (pointer, size, 1, upgrade_file->file) <= 0)
return 0;
}
else
{
if (!upgrade_file_write_integer (upgrade_file, 0))
return 0;
}
return 1;
}
/*
* upgrade_file_create: create an upgrade file
* if write == 1 then it's open in write mode, otherwise
* read mode
*/
struct t_upgrade_file *
upgrade_file_create (const char *filename, int write)
{
int length;
struct t_upgrade_file *new_upgrade_file;
if (!filename)
return NULL;
new_upgrade_file = malloc (sizeof (*new_upgrade_file));
if (new_upgrade_file)
{
/* build name of file */
length = strlen (weechat_home) + 1 + strlen (filename) + 16 + 1;
new_upgrade_file->filename = malloc (length + 1);
if (!new_upgrade_file->filename)
{
free (new_upgrade_file);
return NULL;
}
snprintf (new_upgrade_file->filename, length, "%s/%s.upgrade",
weechat_home, filename);
/* open file in read or write mode */
if (write)
new_upgrade_file->file = fopen (new_upgrade_file->filename, "wb");
else
new_upgrade_file->file = fopen (new_upgrade_file->filename, "rb");
if (!new_upgrade_file->file)
{
free (new_upgrade_file->filename);
free (new_upgrade_file);
return NULL;
}
/* change permissions if write mode */
if (write)
{
chmod (new_upgrade_file->filename, 0600);
/* write signature */
upgrade_file_write_string (new_upgrade_file, UPGRADE_SIGNATURE);
}
/* init positions */
new_upgrade_file->last_read_pos = 0;
new_upgrade_file->last_read_length = 0;
/* add upgrade file to list of upgrade files */
new_upgrade_file->prev_upgrade = last_upgrade_file;
new_upgrade_file->next_upgrade = NULL;
if (upgrade_files)
last_upgrade_file->next_upgrade = new_upgrade_file;
else
upgrade_files = new_upgrade_file;
last_upgrade_file = new_upgrade_file;
}
return new_upgrade_file;
}
/*
* upgrade_file_write_object: write object to file
* return 1 if ok, 0 if error
*/
int
upgrade_file_write_object (struct t_upgrade_file *upgrade_file, int object_id,
struct t_infolist *infolist)
{
int i, argc, length;
char *fields, **argv;
void *buf;
/* write all infolist variables */
infolist_reset_item_cursor (infolist);
while (infolist_next (infolist))
{
/* write object start with id */
if (!upgrade_file_write_integer (upgrade_file, UPGRADE_TYPE_OBJECT_START))
{
UPGRADE_ERROR("write - object type - 'object start'");
return 0;
}
if (!upgrade_file_write_integer (upgrade_file, object_id))
{
UPGRADE_ERROR("write - object id");
return 0;
}
fields = infolist_fields (infolist);
if (fields)
{
argv = string_explode (fields, ",", 0, 0, &argc);
if (argv && (argc > 0))
{
for (i = 0; i < argc; i++)
{
switch (argv[i][0])
{
case 'i': /* integer */
if (!upgrade_file_write_integer (upgrade_file, UPGRADE_TYPE_OBJECT_VAR))
{
UPGRADE_ERROR("write - object type - 'object var'");
return 0;
}
if (!upgrade_file_write_string (upgrade_file, argv[i] + 2))
{
UPGRADE_ERROR("write - variable name");
return 0;
}
if (!upgrade_file_write_integer (upgrade_file, INFOLIST_INTEGER))
{
UPGRADE_ERROR("write - infolist type - 'integer'");
return 0;
}
if (!upgrade_file_write_integer (upgrade_file,
infolist_integer (infolist, argv[i] + 2)))
{
UPGRADE_ERROR("write - integer variable");
return 0;
}
break;
case 's': /* string */
if (!upgrade_file_write_integer (upgrade_file, UPGRADE_TYPE_OBJECT_VAR))
{
UPGRADE_ERROR("write - object type - 'object var'");
return 0;
}
if (!upgrade_file_write_string (upgrade_file, argv[i] + 2))
{
UPGRADE_ERROR("write - variable name");
return 0;
}
if (!upgrade_file_write_integer (upgrade_file, INFOLIST_STRING))
{
UPGRADE_ERROR("write - infolist type - 'string'");
return 0;
}
if (!upgrade_file_write_string (upgrade_file,
infolist_string (infolist, argv[i] + 2)))
{
UPGRADE_ERROR("write - string variable");
return 0;
}
break;
case 'p': /* pointer */
/* pointer in not used in upgrade files, only buffer is */
break;
case 'b': /* buffer */
buf = infolist_buffer (infolist, argv[i] + 2, &length);
if (buf && (length > 0))
{
if (!upgrade_file_write_integer (upgrade_file, UPGRADE_TYPE_OBJECT_VAR))
{
UPGRADE_ERROR("write - object type - 'object var'");
return 0;
}
if (!upgrade_file_write_string (upgrade_file, argv[i] + 2))
{
UPGRADE_ERROR("write - variable name");
return 0;
}
if (!upgrade_file_write_integer (upgrade_file, INFOLIST_BUFFER))
{
UPGRADE_ERROR("write - infolist type - 'buffer'");
return 0;
}
if (!upgrade_file_write_buffer (upgrade_file, buf, length))
{
UPGRADE_ERROR("write - buffer variable");
return 0;
}
}
break;
case 't': /* time */
if (!upgrade_file_write_integer (upgrade_file, UPGRADE_TYPE_OBJECT_VAR))
{
UPGRADE_ERROR("write - object type - 'object var'");
return 0;
}
if (!upgrade_file_write_string (upgrade_file, argv[i] + 2))
{
UPGRADE_ERROR("write - variable name");
return 0;
}
if (!upgrade_file_write_integer (upgrade_file, INFOLIST_TIME))
{
UPGRADE_ERROR("write - infolist type - 'time'");
return 0;
}
if (!upgrade_file_write_time (upgrade_file,
infolist_time (infolist, argv[i] + 2)))
{
UPGRADE_ERROR("write - time variable");
return 0;
}
break;
}
}
}
if (argv)
string_free_exploded (argv);
}
/* write object end */
if (!upgrade_file_write_integer (upgrade_file, UPGRADE_TYPE_OBJECT_END))
return 0;
}
return 1;
}
/*
* upgrade_file_read_integer: read integer from upgrade file
*/
int
upgrade_file_read_integer (struct t_upgrade_file *upgrade_file, int *value)
{
upgrade_file->last_read_pos = ftell (upgrade_file->file);
upgrade_file->last_read_length = sizeof (*value);
if (value)
{
if (fread ((void *)value, sizeof (*value), 1, upgrade_file->file) <= 0)
return 0;
}
else
{
if (fseek (upgrade_file->file, sizeof (*value), SEEK_CUR) < 0)
return 0;
}
return 1;
}
/*
* upgrade_file_read_string: read string from upgrade file
*/
int
upgrade_file_read_string (struct t_upgrade_file *upgrade_file, char **string)
{
int length;
if (string && *string)
{
free (*string);
*string = NULL;
}
if (!upgrade_file_read_integer (upgrade_file, &length))
return 0;
upgrade_file->last_read_pos = ftell (upgrade_file->file);
upgrade_file->last_read_length = length;
if (string)
{
if (length == 0)
return 1;
(*string) = malloc (length + 1);
if (!(*string))
return 0;
if (fread ((void *)(*string), length, 1, upgrade_file->file) <= 0)
{
free (*string);
*string = NULL;
return 0;
}
(*string)[length] = '\0';
}
else
{
if (fseek (upgrade_file->file, length, SEEK_CUR) < 0)
return 0;
}
return 1;
}
/*
* upgrade_file_read_string_utf8: read string from file, then normalize UTF-8
*/
int
upgrade_file_read_string_utf8 (struct t_upgrade_file *upgrade_file,
char **string)
{
if (!upgrade_file_read_string (upgrade_file, string))
return 0;
if (string && *string)
utf8_normalize (*string, '?');
return 1;
}
/*
* upgrade_file_read_buffer: read buffer from upgrade file
*/
int
upgrade_file_read_buffer (struct t_upgrade_file *upgrade_file,
void **buffer, int *size)
{
if (buffer && *buffer)
{
free (*buffer);
*buffer = NULL;
}
if (!upgrade_file_read_integer (upgrade_file, size))
return 0;
if (*size > 0)
{
upgrade_file->last_read_pos = ftell (upgrade_file->file);
upgrade_file->last_read_length = *size;
*buffer = malloc (*size);
if (buffer && *buffer)
{
if (fread (*buffer, *size, 1, upgrade_file->file) <= 0)
return 0;
}
else
{
if (fseek (upgrade_file->file, *size, SEEK_CUR) < 0)
return 0;
}
}
return 1;
}
/*
* upgrade_file_read_time: read time from upgrade file
*/
int
upgrade_file_read_time (struct t_upgrade_file *upgrade_file, time_t *time)
{
upgrade_file->last_read_pos = ftell (upgrade_file->file);
upgrade_file->last_read_length = sizeof (*time);
if (time)
{
if (fread ((void *)time, sizeof (*time), 1, upgrade_file->file) <= 0)
return 0;
}
else
{
if (fseek (upgrade_file->file, sizeof (*time), SEEK_CUR) < 0)
return 0;
}
return 1;
}
/*
* upgrade_file_read_object: read object from file, then call read callback
* return 1 if ok, 0 if error
*/
int
upgrade_file_read_object (struct t_upgrade_file *upgrade_file)
{
struct t_infolist *infolist;
struct t_infolist_item *item;
int rc, object_id, type, type_var, value, size;
char *name, *value_str;
void *buffer;
time_t time;
rc = 0;
infolist = NULL;
name = NULL;
value_str = NULL;
buffer = NULL;
if (!upgrade_file_read_integer (upgrade_file, &type))
{
if (feof (upgrade_file->file))
rc = 1;
else
UPGRADE_ERROR("read - object type");
goto end;
}
if (type != UPGRADE_TYPE_OBJECT_START)
{
UPGRADE_ERROR("read - bad object type (not 'object start')");
goto end;
}
if (!upgrade_file_read_integer (upgrade_file, &object_id))
{
UPGRADE_ERROR("read - object id");
goto end;
}
infolist = infolist_new ();
if (!infolist)
{
UPGRADE_ERROR("read - infolist creation");
goto end;
}
item = infolist_new_item (infolist);
if (!item)
{
UPGRADE_ERROR("read - infolist item creation");
goto end;
}
while (1)
{
if (!upgrade_file_read_integer (upgrade_file, &type))
{
UPGRADE_ERROR("read - object type");
goto end;
}
if (type == UPGRADE_TYPE_OBJECT_END)
break;
if (type == UPGRADE_TYPE_OBJECT_VAR)
{
if (!upgrade_file_read_string (upgrade_file, &name))
{
UPGRADE_ERROR("read - variable name");
goto end;
}
if (!name)
{
UPGRADE_ERROR("read - variable name");
goto end;
}
if (!upgrade_file_read_integer (upgrade_file, &type_var))
{
UPGRADE_ERROR("read - variable type");
goto end;
}
switch (type_var)
{
case INFOLIST_INTEGER:
if (!upgrade_file_read_integer (upgrade_file, &value))
{
UPGRADE_ERROR("read - integer value");
goto end;
}
infolist_new_var_integer (item, name, value);
break;
case INFOLIST_STRING:
if (!upgrade_file_read_string (upgrade_file, &value_str))
{
UPGRADE_ERROR("read - string value");
goto end;
}
infolist_new_var_string (item, name, value_str);
break;
case INFOLIST_POINTER:
break;
case INFOLIST_BUFFER:
if (!upgrade_file_read_buffer (upgrade_file, &buffer, &size))
{
UPGRADE_ERROR("read - buffer value");
goto end;
}
infolist_new_var_buffer (item, name, buffer, size);
break;
case INFOLIST_TIME:
if (!upgrade_file_read_time (upgrade_file, &time))
{
UPGRADE_ERROR("read - time value");
goto end;
}
infolist_new_var_time (item, name, time);
break;
}
}
}
rc = 1;
if (upgrade_file->callback_read)
{
if ((int)(upgrade_file->callback_read) (object_id, infolist) == WEECHAT_RC_ERROR)
rc = 0;
}
end:
if (infolist)
infolist_free (infolist);
if (name)
free (name);
if (value_str)
free (value_str);
if (buffer)
free (buffer);
return rc;
}
/*
* upgrade_file_read: read an upgrade file
*/
int
upgrade_file_read (struct t_upgrade_file *upgrade_file,
int (*callback_read)(int object_id,
struct t_infolist *infolist))
{
char *signature;
upgrade_file->callback_read = callback_read;
signature = NULL;
if (!upgrade_file_read_string (upgrade_file, &signature))
return 0;
if (!signature || (strcmp (signature, UPGRADE_SIGNATURE) != 0))
return 0;
free (signature);
while (!feof (upgrade_file->file))
{
if (!upgrade_file_read_object (upgrade_file))
return 0;
}
return 1;
}
/*
* upgrade_file_close: close an upgrade file
*/
void
upgrade_file_close (struct t_upgrade_file *upgrade_file)
{
fclose (upgrade_file->file);
}
+59
View File
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WEECHAT_UPGRADE_FILE_H
#define __WEECHAT_UPGRADE_FILE_H 1
#define UPGRADE_SIGNATURE "===== WeeChat Upgrade file v2.0 - binary, do not edit! ====="
#define UPGRADE_ERROR(msg) upgrade_file_error(upgrade_file, msg, __FILE__, __LINE__)
struct t_infolist;
enum t_upgrade_type
{
UPGRADE_TYPE_OBJECT_START = 0,
UPGRADE_TYPE_OBJECT_END,
UPGRADE_TYPE_OBJECT_VAR,
};
struct t_upgrade_file
{
char *filename; /* filename with path */
FILE *file; /* file pointer */
long last_read_pos; /* last read position */
int last_read_length; /* last read length */
int (*callback_read) /* callback called when reading */
(int object_id, /* file */
struct t_infolist *infolist);
struct t_upgrade_file *prev_upgrade; /* link to previous upgrade file */
struct t_upgrade_file *next_upgrade; /* link to next upgrade file */
};
extern struct t_upgrade_file *upgrade_file_create (const char *filename,
int write);
extern int upgrade_file_write_object (struct t_upgrade_file *upgrade_file,
int object_id,
struct t_infolist *infolist);
extern int upgrade_file_read (struct t_upgrade_file *upgrade_file,
int (*callback_read)(int object_id,
struct t_infolist *infolist));
extern void upgrade_file_close (struct t_upgrade_file *upgrade_file);
#endif /* wee-upgrade-file.h */
+308 -1735
View File
File diff suppressed because it is too large Load Diff
+11 -174
View File
@@ -20,186 +20,23 @@
#ifndef __WEECHAT_UPGRADE_H
#define __WEECHAT_UPGRADE_H 1
#define WEECHAT_SESSION_NAME "weechat_session.bin"
#include "wee-upgrade-file.h"
#define SESSION_SIGNATURE "== WeeChat Upgrade file v1.0 - binary, do not edit! =="
#define WEECHAT_UPGRADE_FILENAME "weechat"
/* For developers: please add new values ONLY AT THE END of enums */
enum t_session_type
enum t_upgrade_weechat_type
{
SESSION_TYPE_INT = 0,
SESSION_TYPE_STR,
SESSION_TYPE_BUF
UPGRADE_WEECHAT_TYPE_HISTORY = 0,
UPGRADE_WEECHAT_TYPE_BUFFER,
UPGRADE_WEECHAT_TYPE_NICKLIST,
UPGRADE_WEECHAT_TYPE_BUFFER_LINE,
UPGRADE_WEECHAT_TYPE_UPTIME,
UPGRADE_WEECHAT_TYPE_HOTLIST,
};
enum t_session_object
{
SESSION_OBJ_END = 0,
SESSION_OBJ_SERVER,
SESSION_OBJ_CHANNEL,
SESSION_OBJ_NICK,
SESSION_OBJ_DCC,
SESSION_OBJ_HISTORY,
SESSION_OBJ_BUFFER,
SESSION_OBJ_LINE,
SESSION_OBJ_UPTIME,
SESSION_OBJ_HOTLIST
};
enum t_session_server
{
SESSION_SERV_END = 0,
SESSION_SERV_NAME,
SESSION_SERV_AUTOCONNECT,
SESSION_SERV_AUTORECONNECT,
SESSION_SERV_AUTORECONNECT_DELAY,
SESSION_SERV_TEMP_SERVER,
SESSION_SERV_ADDRESS,
SESSION_SERV_PORT,
SESSION_SERV_IPV6,
SESSION_SERV_SSL,
SESSION_SERV_PASSWORD,
SESSION_SERV_NICK1,
SESSION_SERV_NICK2,
SESSION_SERV_NICK3,
SESSION_SERV_USERNAME,
SESSION_SERV_REALNAME,
SESSION_SERV_COMMAND,
SESSION_SERV_COMMAND_DELAY,
SESSION_SERV_AUTOJOIN,
SESSION_SERV_AUTOREJOIN,
SESSION_SERV_NOTIFY_LEVELS,
SESSION_SERV_CHILD_PID,
SESSION_SERV_CHILD_READ,
SESSION_SERV_CHILD_WRITE,
SESSION_SERV_SOCK,
SESSION_SERV_IS_CONNECTED,
SESSION_SERV_SSL_CONNECTED,
SESSION_SERV_GNUTLS_SESS,
SESSION_SERV_UNTERMINATED_MESSAGE,
SESSION_SERV_NICK,
SESSION_SERV_RECONNECT_START,
SESSION_SERV_RECONNECT_JOIN,
SESSION_SERV_IS_AWAY,
SESSION_SERV_AWAY_TIME,
SESSION_SERV_LAG,
SESSION_SERV_LAG_CHECK_TIME,
SESSION_SERV_LAG_NEXT_CHECK,
SESSION_SERV_CHARSET_DECODE_ISO__UNUSED,
SESSION_SERV_CHARSET_DECODE_UTF__UNUSED,
SESSION_SERV_CHARSET_ENCODE__UNUSED,
SESSION_SERV_HOSTNAME,
SESSION_SERV_NICK_MODES,
SESSION_SERV_AWAY_MESSAGE,
SESSION_SERV_PREFIX,
SESSION_SERV_COMMAND_TIME
};
enum t_session_channel
{
SESSION_CHAN_END = 0,
SESSION_CHAN_TYPE,
SESSION_CHAN_NAME,
SESSION_CHAN_TOPIC,
SESSION_CHAN_MODES,
SESSION_CHAN_LIMIT,
SESSION_CHAN_KEY,
SESSION_CHAN_NICKS_COUNT,
SESSION_CHAN_CHECKING_AWAY,
SESSION_CHAN_AWAY_MESSAGE,
SESSION_CHAN_CYCLE,
SESSION_CHAN_CLOSE,
SESSION_CHAN_DISPLAY_CREATION_DATE
};
enum t_session_nick
{
SESSION_NICK_END = 0,
SESSION_NICK_NICK,
SESSION_NICK_FLAGS,
SESSION_NICK_COLOR,
SESSION_NICK_HOST
};
enum t_session_dcc
{
SESSION_DCC_END = 0,
SESSION_DCC_SERVER,
SESSION_DCC_CHANNEL,
SESSION_DCC_TYPE,
SESSION_DCC_STATUS,
SESSION_DCC_START_TIME,
SESSION_DCC_START_TRANSFER,
SESSION_DCC_ADDR,
SESSION_DCC_PORT,
SESSION_DCC_NICK,
SESSION_DCC_SOCK,
SESSION_DCC_UNTERMINATED_MESSAGE,
SESSION_DCC_FILE,
SESSION_DCC_FILENAME,
SESSION_DCC_LOCAL_FILENAME,
SESSION_DCC_FILENAME_SUFFIX,
SESSION_DCC_SIZE,
SESSION_DCC_POS,
SESSION_DCC_ACK,
SESSION_DCC_START_RESUME,
SESSION_DCC_LAST_CHECK_TIME,
SESSION_DCC_LAST_CHECK_POS,
SESSION_DCC_LAST_ACTIVITY,
SESSION_DCC_BYTES_PER_SEC,
SESSION_DCC_ETA,
SESSION_DCC_CHILD_PID,
SESSION_DCC_CHILD_READ,
SESSION_DCC_CHILD_WRITE
};
enum t_session_history
{
SESSION_HIST_END = 0,
SESSION_HIST_TEXT
};
enum t_session_buffer
{
SESSION_BUFF_END = 0,
SESSION_BUFF_SERVER,
SESSION_BUFF_CHANNEL,
SESSION_BUFF_TYPE,
SESSION_BUFF_ALL_SERVERS
};
enum t_session_line
{
SESSION_LINE_END = 0,
SESSION_LINE_LENGTH,
SESSION_LINE_LENGTH_ALIGN,
SESSION_LINE_LOG_WRITE,
SESSION_LINE_WITH_MESSAGE,
SESSION_LINE_WITH_HIGHLIGHT,
SESSION_LINE_DATA,
SESSION_LINE_OFS_AFTER_DATE,
SESSION_LINE_OFS_START_MESSAGE,
SESSION_LINE_NICK,
SESSION_LINE_DATE
};
enum t_session_uptime
{
SESSION_UPT_END = 0,
SESSION_UPT_START_TIME
};
enum t_session_hotlist
{
SESSION_HOTL_END = 0,
SESSION_HOTL_PRIORITY,
SESSION_HOTL_SERVER,
SESSION_HOTL_BUFFER_NUMBER,
SESSION_HOTL_CREATION_TIME
};
int session_save (const char *filename);
int session_load (const char *filename);
int upgrade_weechat_save ();
int upgrade_weechat_load ();
#endif /* wee-upgrade.h */
+9 -17
View File
@@ -58,6 +58,7 @@
#include "wee-log.h"
#include "wee-network.h"
#include "wee-string.h"
#include "wee-upgrade.h"
#include "wee-utf8.h"
#include "wee-util.h"
#include "../gui/gui-chat.h"
@@ -68,7 +69,7 @@
char *weechat_argv0 = NULL; /* WeeChat binary file name (argv[0])*/
char *weechat_session = NULL; /* session file (/upgrade) */
int weechat_upgrading; /* =1 if WeeChat is upgrading */
time_t weechat_start_time; /* start time (used by /uptime cmd) */
int weechat_quit; /* = 1 if quit request from user */
int weechat_sigsegv = 0; /* SIGSEGV received? */
@@ -151,7 +152,7 @@ weechat_parse_args (int argc, char *argv[])
int i;
weechat_argv0 = strdup (argv[0]);
weechat_session = NULL;
weechat_upgrading = 0;
weechat_home = NULL;
weechat_server_cmd_line = 0;
weechat_auto_load_plugins = 1;
@@ -195,18 +196,9 @@ weechat_parse_args (int argc, char *argv[])
{
weechat_auto_load_plugins = 0;
}
else if (strcmp (argv[i], "--session") == 0)
else if (strcmp (argv[i], "--upgrade") == 0)
{
if (i + 1 < argc)
weechat_session = strdup (argv[++i]);
else
{
string_iconv_fprintf (stderr,
_("Error: missing argument for \"%s\" "
"option\n"),
"--session");
weechat_shutdown (EXIT_FAILURE, 0);
}
weechat_upgrading = 1;
}
else if ((strcmp (argv[i], "-v") == 0)
|| (strcmp (argv[i], "--version") == 0))
@@ -383,7 +375,7 @@ main (int argc, char *argv[])
util_catch_signal (SIGQUIT, SIG_IGN); /* ignore SIGQUIT signal */
util_catch_signal (SIGPIPE, SIG_IGN); /* ignore SIGPIPE signal */
util_catch_signal (SIGSEGV,
&debug_sigsegv); /* crash dump for SIGSEGV signal */
&debug_sigsegv); /* crash dump for SIGSEGV signal */
hook_init (); /* initialize hooks */
debug_init (); /* hook signals for debug */
gui_main_pre_init (&argc, &argv); /* pre-initiliaze interface */
@@ -398,11 +390,11 @@ main (int argc, char *argv[])
if (config_weechat_read () < 0) /* read WeeChat configuration */
exit (EXIT_FAILURE);
gui_main_init (); /* init WeeChat interface */
//if (weechat_session)
//session_load (weechat_session); /* load previous session if asked */
if (weechat_upgrading)
upgrade_weechat_load (); /* upgrade with session file */
weechat_welcome_message (); /* display WeeChat welcome message */
command_startup (0); /* command executed before plugins */
plugin_init (weechat_auto_load_plugins, /* init plugin interface(s) */
plugin_init (weechat_auto_load_plugins, /* init plugin interface(s) */
argc, argv);
command_startup (1); /* command executed after plugins */
+194 -23
View File
@@ -35,6 +35,7 @@
#include "../core/weechat.h"
#include "../core/wee-config.h"
#include "../core/wee-hook.h"
#include "../core/wee-infolist.h"
#include "../core/wee-log.h"
#include "../core/wee-string.h"
#include "../core/wee-utf8.h"
@@ -98,6 +99,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
{
/* init buffer */
new_buffer->plugin = plugin;
new_buffer->plugin_name_for_upgrade = NULL;
new_buffer->number = (last_gui_buffer) ? last_gui_buffer->number + 1 : 1;
new_buffer->category = (category) ? strdup (category) : NULL;
new_buffer->name = strdup (name);
@@ -208,9 +210,9 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
}
/*
* buffer_valid: check if a buffer pointer exists
* return 1 if buffer exists
* 0 if buffer is not found
* gui_buffer_valid: check if a buffer pointer exists
* return 1 if buffer exists
* 0 if buffer is not found
*/
int
@@ -233,6 +235,30 @@ gui_buffer_valid (struct t_gui_buffer *buffer)
return 0;
}
/*
* gui_buffer_set_plugin_for_upgrade: set plugin pointer for buffers with a
* given name (used after /upgrade)
*/
void
gui_buffer_set_plugin_for_upgrade (char *name, struct t_weechat_plugin *plugin)
{
struct t_gui_buffer *ptr_buffer;
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
if (ptr_buffer->plugin_name_for_upgrade
&& (strcmp (ptr_buffer->plugin_name_for_upgrade, name) == 0))
{
free (ptr_buffer->plugin_name_for_upgrade);
ptr_buffer->plugin_name_for_upgrade = NULL;
ptr_buffer->plugin = plugin;
}
}
}
/*
* gui_buffer_get_integer: get a buffer property as integer
*/
@@ -488,25 +514,28 @@ gui_buffer_set_highlight_tags (struct t_gui_buffer *buffer,
void
gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
const char *value)
void *value)
{
const char *value_str;
long number;
char *error;
if (!property || !value)
return;
value_str = (const char *)value;
/* properties that does NOT need a buffer */
if (string_strcasecmp (property, "hotlist") == 0)
{
if (strcmp (value, "-") == 0)
if (strcmp (value_str, "-") == 0)
gui_add_hotlist = 0;
else if (strcmp (value, "+") == 0)
else if (strcmp (value_str, "+") == 0)
gui_add_hotlist = 1;
else
{
error = NULL;
number = strtol (value, &error, 10);
number = strtol (value_str, &error, 10);
if (error && !error[0])
gui_hotlist_add (buffer, number, NULL, 1);
}
@@ -516,30 +545,46 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
return;
/* properties that need a buffer */
if (string_strcasecmp (property, "display") == 0)
if (string_strcasecmp (property, "close_callback") == 0)
{
buffer->close_callback = value;
}
else if (string_strcasecmp (property, "close_callback_data") == 0)
{
buffer->close_callback_data = value;
}
else if (string_strcasecmp (property, "input_callback") == 0)
{
buffer->input_callback = value;
}
else if (string_strcasecmp (property, "input_callback_data") == 0)
{
buffer->input_callback_data = value;
}
else if (string_strcasecmp (property, "display") == 0)
{
gui_window_switch_to_buffer (gui_current_window, buffer);
gui_window_redraw_buffer (buffer);
}
else if (string_strcasecmp (property, "category") == 0)
{
gui_buffer_set_category (buffer, value);
gui_buffer_set_category (buffer, value_str);
}
else if (string_strcasecmp (property, "name") == 0)
{
gui_buffer_set_name (buffer, value);
gui_buffer_set_name (buffer, value_str);
}
else if (string_strcasecmp (property, "type") == 0)
{
if (string_strcasecmp (value, "formated") == 0)
if (string_strcasecmp (value_str, "formated") == 0)
gui_buffer_set_type (buffer, GUI_BUFFER_TYPE_FORMATED);
else if (string_strcasecmp (value, "free") == 0)
else if (string_strcasecmp (value_str, "free") == 0)
gui_buffer_set_type (buffer, GUI_BUFFER_TYPE_FREE);
}
else if (string_strcasecmp (property, "notify") == 0)
{
error = NULL;
number = strtol (value, &error, 10);
number = strtol (value_str, &error, 10);
if (error && !error[0]
&& (number < GUI_BUFFER_NUM_NOTIFY))
{
@@ -551,44 +596,44 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
}
else if (string_strcasecmp (property, "title") == 0)
{
gui_buffer_set_title (buffer, value);
gui_buffer_set_title (buffer, value_str);
}
else if (string_strcasecmp (property, "nicklist") == 0)
{
error = NULL;
number = strtol (value, &error, 10);
number = strtol (value_str, &error, 10);
if (error && !error[0])
gui_buffer_set_nicklist (buffer, number);
}
else if (string_strcasecmp (property, "nicklist_case_sensitive") == 0)
{
error = NULL;
number = strtol (value, &error, 10);
number = strtol (value_str, &error, 10);
if (error && !error[0])
gui_buffer_set_nicklist_case_sensitive (buffer, number);
}
else if (string_strcasecmp (property, "nicklist_display_groups") == 0)
{
error = NULL;
number = strtol (value, &error, 10);
number = strtol (value_str, &error, 10);
if (error && !error[0])
gui_buffer_set_nicklist_display_groups (buffer, number);
}
else if (string_strcasecmp (property, "nick") == 0)
{
gui_buffer_set_nick (buffer, value);
gui_buffer_set_nick (buffer, value_str);
}
else if (string_strcasecmp (property, "highlight_words") == 0)
{
gui_buffer_set_highlight_words (buffer, value);
gui_buffer_set_highlight_words (buffer, value_str);
}
else if (string_strcasecmp (property, "highlight_tags") == 0)
{
gui_buffer_set_highlight_tags (buffer, value);
gui_buffer_set_highlight_tags (buffer, value_str);
}
else if (string_strncasecmp (property, "key_bind_", 9) == 0)
{
gui_keyboard_bind (buffer, property + 9, value);
gui_keyboard_bind (buffer, property + 9, value_str);
}
else if (string_strncasecmp (property, "key_unbind_", 11) == 0)
{
@@ -600,7 +645,7 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
else if (string_strcasecmp (property, "input") == 0)
{
gui_input_delete_line (buffer);
gui_input_insert_string (buffer, value, 0);
gui_input_insert_string (buffer, value_str, 0);
gui_input_text_changed_signal ();
gui_buffer_ask_input_refresh (buffer, 1);
}
@@ -1096,6 +1141,132 @@ gui_buffer_move_to_number (struct t_gui_buffer *buffer, int number)
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
}
/*
* gui_buffer_add_to_infolist: add a buffer in an infolist
* return 1 if ok, 0 if error
*/
int
gui_buffer_add_to_infolist (struct t_infolist *infolist,
struct t_gui_buffer *buffer)
{
struct t_infolist_item *ptr_item;
if (!infolist || !buffer)
return 0;
ptr_item = infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (!infolist_new_var_pointer (ptr_item, "pointer", buffer))
return 0;
if (!infolist_new_var_integer (ptr_item, "current_buffer",
(gui_current_window->buffer == buffer) ? 1 : 0))
return 0;
if (!infolist_new_var_pointer (ptr_item, "plugin", buffer->plugin))
return 0;
if (!infolist_new_var_string (ptr_item, "plugin_name",
(buffer->plugin) ?
buffer->plugin->name : NULL))
return 0;
if (!infolist_new_var_integer (ptr_item, "number", buffer->number))
return 0;
if (!infolist_new_var_string (ptr_item, "category", buffer->category))
return 0;
if (!infolist_new_var_string (ptr_item, "name", buffer->name))
return 0;
if (!infolist_new_var_integer (ptr_item, "type", buffer->type))
return 0;
if (!infolist_new_var_integer (ptr_item, "notify", buffer->notify))
return 0;
if (!infolist_new_var_integer (ptr_item, "num_displayed", buffer->num_displayed))
return 0;
if (!infolist_new_var_integer (ptr_item, "lines_hidden", buffer->lines_hidden))
return 0;
if (!infolist_new_var_integer (ptr_item, "nicklist_case_sensitive", buffer->nicklist_case_sensitive))
return 0;
if (!infolist_new_var_integer (ptr_item, "nicklist_display_groups", buffer->nicklist_display_groups))
return 0;
if (!infolist_new_var_string (ptr_item, "title", buffer->title))
return 0;
if (!infolist_new_var_integer (ptr_item, "input", buffer->input))
return 0;
if (!infolist_new_var_string (ptr_item, "input_nick", buffer->input_nick))
return 0;
if (!infolist_new_var_string (ptr_item, "input_string", buffer->input_buffer))
return 0;
return 1;
}
/*
* gui_buffer_line_add_to_infolist: add a buffer line in an infolist
* return 1 if ok, 0 if error
*/
int
gui_buffer_line_add_to_infolist (struct t_infolist *infolist,
struct t_gui_line *line)
{
struct t_infolist_item *ptr_item;
int i, length;
char option_name[64], *tags;
if (!infolist || !line)
return 0;
ptr_item = infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (!infolist_new_var_time (ptr_item, "date", line->date))
return 0;
if (!infolist_new_var_time (ptr_item, "date_printed", line->date))
return 0;
if (!infolist_new_var_string (ptr_item, "str_time", line->str_time))
return 0;
/* write tags */
if (!infolist_new_var_integer (ptr_item, "tags_count", line->tags_count))
return 0;
for (i = 0; i < line->tags_count; i++)
{
snprintf (option_name, sizeof (option_name), "tag_%05d", i + 1);
if (!infolist_new_var_string (ptr_item, option_name,
line->tags_array[i]))
return 0;
length += strlen (line->tags_array[i]) + 1;
}
tags = malloc (length + 1);
if (!tags)
return 0;
tags[0] = '\0';
for (i = 0; i < line->tags_count; i++)
{
strcat (tags, line->tags_array[i]);
if (i < line->tags_count - 1)
strcat (tags, ",");
}
if (!infolist_new_var_string (ptr_item, "tags", tags))
{
free (tags);
return 0;
}
free (tags);
if (!infolist_new_var_integer (ptr_item, "displayed", line->displayed))
return 0;
if (!infolist_new_var_integer (ptr_item, "highlight", line->highlight))
return 0;
if (!infolist_new_var_string (ptr_item, "prefix", line->prefix))
return 0;
if (!infolist_new_var_string (ptr_item, "message", line->message))
return 0;
return 1;
}
/*
* gui_buffer_dump_hexa: dump content of buffer as hexa data in log file
*/
+14 -1
View File
@@ -20,6 +20,8 @@
#ifndef __WEECHAT_GUI_BUFFER_H
#define __WEECHAT_GUI_BUFFER_H 1
struct t_infolist;
enum t_gui_buffer_type
{
GUI_BUFFER_TYPE_FORMATED = 0,
@@ -68,6 +70,11 @@ struct t_gui_buffer
{
struct t_weechat_plugin *plugin; /* plugin which created this buffer */
/* (NULL for a WeeChat buffer) */
/* when upgrading, plugins are not loaded, so we use next variable
to store plugin name, then restore plugin pointer when plugin is
loaded */
char *plugin_name_for_upgrade; /* plugin name when upgrading */
int number; /* buffer number (for jump/switch) */
char *category; /* category name */
char *name; /* buffer name */
@@ -172,6 +179,8 @@ extern struct t_gui_buffer *gui_buffer_new (struct t_weechat_plugin *plugin,
struct t_gui_buffer *buffer),
void *close_callback_data);
extern int gui_buffer_valid (struct t_gui_buffer *buffer);
extern void gui_buffer_set_plugin_for_upgrade (char *name,
struct t_weechat_plugin *plugin);
extern int gui_buffer_get_integer (struct t_gui_buffer *buffer,
const char *property);
extern char *gui_buffer_get_string (struct t_gui_buffer *buffer,
@@ -197,7 +206,7 @@ extern void gui_buffer_set_nicklist_case_sensitive (struct t_gui_buffer * buffer
int case_sensitive);
extern void gui_buffer_set_nick (struct t_gui_buffer *buffer, const char *new_nick);
extern void gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
const char *value);
void *value);
extern struct t_gui_buffer *gui_buffer_search_main ();
extern struct t_gui_buffer *gui_buffer_search_by_category_name (const char *category,
const char *name);
@@ -216,6 +225,10 @@ extern void gui_buffer_switch_next (struct t_gui_window *window);
extern void gui_buffer_switch_by_number (struct t_gui_window *window,
int number);
extern void gui_buffer_move_to_number (struct t_gui_buffer *buffer, int number);
extern int gui_buffer_add_to_infolist (struct t_infolist *infolist,
struct t_gui_buffer *buffer);
extern int gui_buffer_line_add_to_infolist (struct t_infolist *infolist,
struct t_gui_line *line);
extern void gui_buffer_dump_hexa (struct t_gui_buffer *buffer);
extern void gui_buffer_print_log ();
+10 -11
View File
@@ -47,6 +47,7 @@
#include "gui-window.h"
char *gui_chat_buffer = NULL; /* buffer for printf */
char *gui_chat_prefix[GUI_CHAT_NUM_PREFIXES]; /* prefixes */
char gui_chat_prefix_empty[] = ""; /* empty prefix */
int gui_chat_time_length = 0; /* length of time for each line (in chars) */
@@ -899,7 +900,6 @@ void
gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
const char *tags, const char *message, ...)
{
char *buf;
va_list argptr;
time_t date_printed;
int display_time;
@@ -924,15 +924,16 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
return;
}
buf = malloc (GUI_CHAT_BUFFER_PRINTF_SIZE);
if (!buf)
if (!gui_chat_buffer)
gui_chat_buffer = malloc (GUI_CHAT_BUFFER_PRINTF_SIZE);
if (!gui_chat_buffer)
return;
va_start (argptr, message);
vsnprintf (buf, GUI_CHAT_BUFFER_PRINTF_SIZE, message, argptr);
vsnprintf (gui_chat_buffer, GUI_CHAT_BUFFER_PRINTF_SIZE, message, argptr);
va_end (argptr);
utf8_normalize (buf, '?');
utf8_normalize (gui_chat_buffer, '?');
date_printed = time (NULL);
if (date <= 0)
@@ -941,14 +942,14 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
if (gui_init_ok)
ptr_line = buffer->last_line;
pos = buf;
pos = gui_chat_buffer;
while (pos)
{
pos_prefix = NULL;
display_time = 1;
/* if two first chars are tab, then do not display time */
if ((buf[0] == '\t') && (buf[1] == '\t'))
if ((pos[0] == '\t') && (pos[1] == '\t'))
{
display_time = 0;
pos += 2;
@@ -956,11 +957,11 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
else
{
/* if tab found, use prefix (before tab) */
pos_tab = strchr (buf, '\t');
pos_tab = strchr (pos, '\t');
if (pos_tab)
{
pos_tab[0] = '\0';
pos_prefix = buf;
pos_prefix = pos;
pos = pos_tab + 1;
}
}
@@ -996,8 +997,6 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
if (gui_init_ok)
gui_buffer_ask_chat_refresh (buffer, 1);
free (buf);
}
/*
+5
View File
@@ -77,6 +77,11 @@ extern int gui_chat_line_match_tags (struct t_gui_line *line, int tags_count,
extern void gui_chat_line_free (struct t_gui_buffer *buffer,
struct t_gui_line *line);
extern void gui_chat_line_free_all (struct t_gui_buffer *buffer);
extern void gui_chat_line_add (struct t_gui_buffer *buffer, time_t date,
time_t date_printed, const char *tags,
const char *prefix, const char *message);
extern void gui_chat_line_add_y (struct t_gui_buffer *buffer, int y,
const char *message);
extern void gui_chat_printf_date_tags (struct t_gui_buffer *buffer,
time_t date, const char *tags,
const char *message, ...);
+10 -10
View File
@@ -34,7 +34,7 @@
struct t_gui_history *history_global = NULL;
struct t_gui_history *history_global_last = NULL;
struct t_gui_history *last_history_global = NULL;
struct t_gui_history *history_global_ptr = NULL;
int num_history_global = 0;
@@ -115,7 +115,7 @@ gui_history_global_add (const char *string)
if (history_global)
history_global->prev_history = new_history;
else
history_global_last = new_history;
last_history_global = new_history;
new_history->next_history = history_global;
new_history->prev_history = NULL;
history_global = new_history;
@@ -125,14 +125,14 @@ gui_history_global_add (const char *string)
if ((CONFIG_INTEGER(config_history_max_commands) > 0)
&& (num_history_global > CONFIG_INTEGER(config_history_max_commands)))
{
ptr_history = history_global_last->prev_history;
if (history_global_ptr == history_global_last)
ptr_history = last_history_global->prev_history;
if (history_global_ptr == last_history_global)
history_global_ptr = ptr_history;
history_global_last->prev_history->next_history = NULL;
if (history_global_last->text)
free (history_global_last->text);
free (history_global_last);
history_global_last = ptr_history;
last_history_global->prev_history->next_history = NULL;
if (last_history_global->text)
free (last_history_global->text);
free (last_history_global);
last_history_global = ptr_history;
num_history_global--;
}
}
@@ -157,7 +157,7 @@ gui_history_global_free ()
history_global = ptr_history;
}
history_global = NULL;
history_global_last = NULL;
last_history_global = NULL;
history_global_ptr = NULL;
num_history_global = 0;
}
+1 -1
View File
@@ -30,7 +30,7 @@ struct t_gui_history
};
extern struct t_gui_history *history_global;
extern struct t_gui_history *history_global_last;
extern struct t_gui_history *last_history_global;
extern struct t_gui_history *history_global_ptr;
/* history functions (gui-history.c) */
+29
View File
@@ -29,6 +29,7 @@
#include "../core/weechat.h"
#include "../core/wee-config.h"
#include "../core/wee-hook.h"
#include "../core/wee-infolist.h"
#include "../core/wee-log.h"
#include "../core/wee-util.h"
#include "../plugins/plugin.h"
@@ -377,6 +378,34 @@ gui_hotlist_remove_buffer (struct t_gui_buffer *buffer)
gui_hotlist_free (&gui_hotlist, &last_gui_hotlist, pos_hotlist);
}
/*
* gui_hotlist_add_to_infolist: add a hotlist in an infolist
* return 1 if ok, 0 if error
*/
int
gui_hotlist_add_to_infolist (struct t_infolist *infolist,
struct t_gui_hotlist *hotlist)
{
struct t_infolist_item *ptr_item;
if (!infolist || !hotlist)
return 0;
ptr_item = infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (!infolist_new_var_integer (ptr_item, "priority", hotlist->priority))
return 0;
if (!infolist_new_var_buffer (ptr_item, "creation_time", &(hotlist->creation_time), sizeof (struct timeval)))
return 0;
if (!infolist_new_var_integer (ptr_item, "buffer_number", hotlist->buffer->number))
return 0;
return 1;
}
/*
* gui_hotlist_print_log: print hotlist in log (usually for crash dump)
*/
+2
View File
@@ -57,6 +57,8 @@ extern void gui_hotlist_free (struct t_gui_hotlist **hotlist,
extern void gui_hotlist_free_all (struct t_gui_hotlist **hotlist,
struct t_gui_hotlist **last_hotlist);
extern void gui_hotlist_remove_buffer (struct t_gui_buffer *buffer);
extern int gui_hotlist_add_to_infolist (struct t_infolist *infolist,
struct t_gui_hotlist *hotlist);
extern void gui_hotlist_print_log ();
#endif /* gui-hotlist.h */
+73
View File
@@ -34,6 +34,7 @@
#include "../core/weechat.h"
#include "../core/wee-hook.h"
#include "../core/wee-infolist.h"
#include "../core/wee-log.h"
#include "../core/wee-string.h"
#include "../core/wee-utf8.h"
@@ -609,6 +610,78 @@ gui_nicklist_compute_visible_count (struct t_gui_buffer *buffer,
buffer->nicklist_visible_count++;
}
/*
* gui_nicklist_add_to_infolist: add a nicklist in an infolist
* return 1 if ok, 0 if error
*/
int
gui_nicklist_add_to_infolist (struct t_infolist *infolist,
struct t_gui_buffer *buffer)
{
struct t_infolist_item *ptr_item;
struct t_gui_nick_group *ptr_group;
struct t_gui_nick *ptr_nick;
char prefix[2];
if (!infolist || !buffer)
return 0;
ptr_group = NULL;
ptr_nick = NULL;
gui_nicklist_get_next_item (buffer, &ptr_group, &ptr_nick);
while (ptr_group || ptr_nick)
{
ptr_item = infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (ptr_nick)
{
if (!infolist_new_var_string (ptr_item, "type", "nick"))
return 0;
if (ptr_nick->group)
{
if (!infolist_new_var_string (ptr_item, "group_name", ptr_nick->group->name))
return 0;
}
if (!infolist_new_var_string (ptr_item, "name", ptr_nick->name))
return 0;
if (!infolist_new_var_string (ptr_item, "color", ptr_nick->color))
return 0;
prefix[0] = ptr_nick->prefix;
prefix[1] = '\0';
if (!infolist_new_var_string (ptr_item, "prefix", prefix))
return 0;
if (!infolist_new_var_string (ptr_item, "prefix_color", ptr_nick->prefix_color))
return 0;
if (!infolist_new_var_integer (ptr_item, "visible", ptr_nick->visible))
return 0;
}
else
{
if (!infolist_new_var_string (ptr_item, "type", "group"))
return 0;
if (ptr_group->parent)
{
if (!infolist_new_var_string (ptr_item, "parent_name", ptr_group->parent->name))
return 0;
}
if (!infolist_new_var_string (ptr_item, "name", ptr_group->name))
return 0;
if (!infolist_new_var_string (ptr_item, "color", ptr_group->color))
return 0;
if (!infolist_new_var_integer (ptr_item, "visible", ptr_group->visible))
return 0;
if (!infolist_new_var_integer (ptr_item, "level", ptr_group->level))
return 0;
}
gui_nicklist_get_next_item (buffer, &ptr_group, &ptr_nick);
}
return 1;
}
/*
* gui_nicklist_print_log: print nicklist infos in log (usually for crash dump)
*/
+3
View File
@@ -21,6 +21,7 @@
#define __WEECHAT_GUI_NICKLIST_H 1
struct t_gui_buffer;
struct t_infolist;
struct t_gui_nick_group
{
@@ -79,6 +80,8 @@ extern int gui_nicklist_get_max_length (struct t_gui_buffer *buffer,
struct t_gui_nick_group *group);
extern void gui_nicklist_compute_visible_count (struct t_gui_buffer *buffer,
struct t_gui_nick_group *group);
extern int gui_nicklist_add_to_infolist (struct t_infolist *infolist,
struct t_gui_buffer *buffer);
extern void gui_nicklist_print_log (struct t_gui_nick_group *group, int indent);
/* nicklist functions (GUI dependent) */
+88
View File
@@ -35,6 +35,7 @@
#include "../core/weechat.h"
#include "../core/wee-config.h"
#include "../core/wee-hook.h"
#include "../core/wee-infolist.h"
#include "../core/wee-log.h"
#include "../core/wee-utf8.h"
#include "../plugins/plugin.h"
@@ -880,6 +881,93 @@ gui_window_search_stop (struct t_gui_window *window)
gui_buffer_ask_input_refresh (window->buffer, 1);
}
/*
* gui_window_add_to_infolist: add a window in an infolist
* return 1 if ok, 0 if error
*/
int
gui_window_add_to_infolist (struct t_infolist *infolist,
struct t_gui_window *window)
{
struct t_infolist_item *ptr_item;
if (!infolist || !window)
return 0;
ptr_item = infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (!infolist_new_var_pointer (ptr_item, "pointer", window))
return 0;
if (!infolist_new_var_integer (ptr_item, "x", window->win_x))
return 0;
if (!infolist_new_var_integer (ptr_item, "y", window->win_y))
return 0;
if (!infolist_new_var_integer (ptr_item, "width", window->win_width))
return 0;
if (!infolist_new_var_integer (ptr_item, "height", window->win_height))
return 0;
if (!infolist_new_var_integer (ptr_item, "width_pct", window->win_width_pct))
return 0;
if (!infolist_new_var_integer (ptr_item, "height_pct", window->win_height_pct))
return 0;
if (!infolist_new_var_integer (ptr_item, "chat_x", window->win_chat_x))
return 0;
if (!infolist_new_var_integer (ptr_item, "chat_y", window->win_chat_y))
return 0;
if (!infolist_new_var_integer (ptr_item, "chat_width", window->win_chat_width))
return 0;
if (!infolist_new_var_integer (ptr_item, "chat_height", window->win_chat_height))
return 0;
if (!infolist_new_var_integer (ptr_item, "nick_x", window->win_nick_x))
return 0;
if (!infolist_new_var_integer (ptr_item, "nick_y", window->win_nick_y))
return 0;
if (!infolist_new_var_integer (ptr_item, "nick_width", window->win_nick_width))
return 0;
if (!infolist_new_var_integer (ptr_item, "nick_height", window->win_nick_height))
return 0;
if (!infolist_new_var_integer (ptr_item, "nick_start", window->win_nick_start))
return 0;
if (!infolist_new_var_integer (ptr_item, "title_x", window->win_title_x))
return 0;
if (!infolist_new_var_integer (ptr_item, "title_y", window->win_title_y))
return 0;
if (!infolist_new_var_integer (ptr_item, "title_width", window->win_title_width))
return 0;
if (!infolist_new_var_integer (ptr_item, "title_start", window->win_title_start))
return 0;
if (!infolist_new_var_integer (ptr_item, "status_x", window->win_status_x))
return 0;
if (!infolist_new_var_integer (ptr_item, "status_y", window->win_status_y))
return 0;
if (!infolist_new_var_integer (ptr_item, "status_width", window->win_status_width))
return 0;
if (!infolist_new_var_integer (ptr_item, "status_height", window->win_status_height))
return 0;
if (!infolist_new_var_integer (ptr_item, "input_x", window->win_input_x))
return 0;
if (!infolist_new_var_integer (ptr_item, "input_y", window->win_input_y))
return 0;
if (!infolist_new_var_integer (ptr_item, "input_width", window->win_input_width))
return 0;
if (!infolist_new_var_integer (ptr_item, "input_height", window->win_input_height))
return 0;
if (!infolist_new_var_integer (ptr_item, "input_cursor_x", window->win_input_cursor_x))
return 0;
if (!infolist_new_var_pointer (ptr_item, "buffer", window->buffer))
return 0;
if (!infolist_new_var_integer (ptr_item, "start_line_y",
((window->buffer->type == GUI_BUFFER_TYPE_FREE)
&& (window->start_line)) ?
window->start_line->y : 0))
return 0;
return 1;
}
/*
* gui_window_print_log: print window infos in log (usually for crash dump)
*/
+4
View File
@@ -20,6 +20,8 @@
#ifndef __WEECHAT_GUI_WINDOW_H
#define __WEECHAT_GUI_WINDOW_H 1
struct t_infolist;
extern int gui_init_ok;
extern int gui_ok;
extern int gui_window_refresh_needed;
@@ -135,6 +137,8 @@ extern void gui_window_search_start (struct t_gui_window *window);
extern void gui_window_search_restart (struct t_gui_window *window);
extern void gui_window_search_stop (struct t_gui_window *window);
extern int gui_window_search_text (struct t_gui_window *window);
extern int gui_window_add_to_infolist (struct t_infolist *infolist,
struct t_gui_window *window);
extern void gui_window_print_log ();
/* window functions (GUI dependent) */
+5 -3
View File
@@ -14,9 +14,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
SET(LIB_PLUGINS_SRC weechat-plugin.h plugin.c plugin.h plugin-api.c
plugin-api.h plugin-config.h plugin-config.c plugin-infolist.c
plugin-infolist.h)
SET(LIB_PLUGINS_SRC
weechat-plugin.h
plugin.c plugin.h
plugin-api.c plugin-api.h
plugin-config.h plugin-config.c)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
ADD_LIBRARY(weechat_plugins STATIC ${LIB_PLUGINS_SRC})
+1 -3
View File
@@ -24,9 +24,7 @@ lib_weechat_plugins_a_SOURCES = weechat-plugin.h \
plugin-api.c \
plugin-api.h \
plugin-config.c \
plugin-config.h \
plugin-infolist.c \
plugin-infolist.h
plugin-config.h
if PLUGIN_ALIAS
alias_dir = alias
+16 -6
View File
@@ -203,11 +203,12 @@ demo_buffer_set_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
*/
void
demo_infolist_print (struct t_plugin_infolist *infolist, const char *item_name)
demo_infolist_print (struct t_infolist *infolist, const char *item_name)
{
char *fields, **argv;
int i, j, argc;
time_t date;
void *pointer;
int i, j, argc, size;
time_t time;
i = 1;
while (weechat_infolist_next (infolist))
@@ -241,11 +242,20 @@ demo_infolist_print (struct t_plugin_infolist *infolist, const char *item_name)
weechat_infolist_pointer (infolist,
argv[j] + 2));
break;
case 'b':
pointer = weechat_infolist_buffer (infolist,
argv[j] + 2,
&size);
weechat_printf (NULL, " %s: %X (size: %d)",
argv[j] + 2,
pointer,
size);
break;
case 't':
date = weechat_infolist_time (infolist, argv[j] + 2);
time = weechat_infolist_time (infolist, argv[j] + 2);
weechat_printf (NULL, " %s: (%ld) %s",
argv[j] + 2,
date, ctime (&date));
time, ctime (&time));
break;
}
}
@@ -265,7 +275,7 @@ int
demo_infolist_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
struct t_plugin_infolist *infolist;
struct t_infolist *infolist;
/* make C compiler happy */
(void) data;
+2 -1
View File
@@ -28,7 +28,8 @@ irc-input.c irc-input.h
irc-mode.c irc-mode.h
irc-nick.c irc-nick.h
irc-protocol.c irc-protocol.h
irc-server.c irc-server.h)
irc-server.c irc-server.h
irc-upgrade.c irc-upgrade.h)
SET_TARGET_PROPERTIES(irc PROPERTIES PREFIX "")
CHECK_INCLUDE_FILES("regex.h" HAVE_REGEX_H)
+3 -1
View File
@@ -47,7 +47,9 @@ irc_la_SOURCES = irc.c \
irc-protocol.c \
irc-protocol.h \
irc-server.c \
irc-server.h
irc-server.h \
irc-upgrade.c \
irc-upgrade.h
irc_la_LDFLAGS = -module
irc_la_LIBADD = $(IRC_LFLAGS) $(GNUTLS_LFLAGS)
+75 -8
View File
@@ -53,16 +53,23 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
weechat_prefix ("error"), "irc");
return NULL;
}
/* create buffer for channel */
new_buffer = weechat_buffer_new (server->name, channel_name,
&irc_input_data_cb, NULL,
&irc_buffer_close_cb, NULL);
if (!new_buffer)
/* create buffer for channel (or use existing one) */
new_buffer = weechat_buffer_search (server->name, channel_name);
if (new_buffer)
weechat_nicklist_remove_all (new_buffer);
else
{
free (new_channel);
return NULL;
new_buffer = weechat_buffer_new (server->name, channel_name,
&irc_input_data_cb, NULL,
&irc_buffer_close_cb, NULL);
if (!new_buffer)
{
free (new_channel);
return NULL;
}
}
if (channel_type == IRC_CHANNEL_TYPE_CHANNEL)
{
weechat_buffer_set (new_buffer, "nick", server->nick);
@@ -124,6 +131,20 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
return new_channel;
}
/*
* irc_channel_set_topic: set topic for a channel
*/
void
irc_channel_set_topic (struct t_irc_channel *channel, char *topic)
{
if (channel->topic)
free (channel->topic);
channel->topic = (topic) ? strdup (topic) : NULL;
weechat_buffer_set (channel->buffer, "title", channel->topic);
}
/*
* irc_channel_free: free a channel and remove it from channels list
*/
@@ -353,6 +374,52 @@ irc_channel_add_nick_speaking (struct t_irc_channel *channel, const char *nick)
}
}
/*
* irc_channel_add_to_infolist: add a channel in an infolist
* return 1 if ok, 0 if error
*/
int
irc_channel_add_to_infolist (struct t_infolist *infolist,
struct t_irc_channel *channel)
{
struct t_infolist_item *ptr_item;
if (!infolist || !channel)
return 0;
ptr_item = weechat_infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "type", channel->type))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "name", channel->name))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "topic", channel->topic))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "modes", channel->modes))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "limit", channel->limit))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "key", channel->key))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "nicks_count", channel->nicks_count))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "checking_away", channel->checking_away))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "away_message", channel->away_message))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "cycle", channel->cycle))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "display_creation_date", channel->display_creation_date))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "nick_completion_reset", channel->nick_completion_reset))
return 0;
return 1;
}
/*
* irc_channel_print_log: print channel infos in log (usually for crash dump)
*/
+3
View File
@@ -58,6 +58,7 @@ extern struct t_irc_channel *irc_channel_new (struct t_irc_server *server,
int channel_type,
const char *channel_name,
int switch_to_channel);
extern void irc_channel_set_topic (struct t_irc_channel *channel, char *topic);
extern void irc_channel_free (struct t_irc_server *server,
struct t_irc_channel *channel);
extern void irc_channel_free_all (struct t_irc_server *server);
@@ -75,6 +76,8 @@ extern void irc_channel_set_away (struct t_irc_channel *channel, const char *nic
int is_away);
extern void irc_channel_add_nick_speaking (struct t_irc_channel *channel,
const char *nick);
extern int irc_channel_add_to_infolist (struct t_infolist *infolist,
struct t_irc_channel *channel);
extern void irc_channel_print_log (struct t_irc_channel *channel);
#endif /* irc-channel.h */
+2 -2
View File
@@ -860,8 +860,8 @@ irc_command_dcc (void *data, struct t_gui_buffer *buffer, int argc,
struct sockaddr_in addr;
socklen_t length;
unsigned long address;
struct t_plugin_infolist *infolist;
struct t_plugin_infolist_item *item;
struct t_infolist *infolist;
struct t_infolist_item *item;
char plugin_id[128], str_address[128];
IRC_GET_SERVER_CHANNEL(buffer);
+2 -2
View File
@@ -295,7 +295,7 @@ irc_config_server_delete_cb (void *data, struct t_config_option *option)
int i, index_option, length;
char *name, *mask;
struct t_irc_server *ptr_server;
struct t_plugin_infolist *infolist;
struct t_infolist *infolist;
index_option = irc_config_search_server_option (data);
if (index_option >= 0)
@@ -340,7 +340,7 @@ irc_config_server_delete_cb (void *data, struct t_config_option *option)
void
irc_config_reload_servers_from_config ()
{
struct t_plugin_infolist *infolist;
struct t_infolist *infolist;
struct t_irc_server *ptr_server;
struct t_config_option *ptr_option;
char *name, *full_name, *server_name, *pos_option;
+30
View File
@@ -555,6 +555,36 @@ irc_nick_as_prefix (struct t_irc_nick *nick, const char *nickname,
return result;
}
/*
* irc_nick_add_to_infolist: add a nick in an infolist
* return 1 if ok, 0 if error
*/
int
irc_nick_add_to_infolist (struct t_infolist *infolist,
struct t_irc_nick *nick)
{
struct t_infolist_item *ptr_item;
if (!infolist || !nick)
return 0;
ptr_item = weechat_infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "name", nick->name))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "host", nick->host))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "flags", nick->flags))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "color", nick->color))
return 0;
return 1;
}
/*
* irc_nick_print_log: print nick infos in log (usually for crash dump)
*/
+7 -5
View File
@@ -24,11 +24,11 @@
#define IRC_NICK_CHANOWNER 1
#define IRC_NICK_CHANADMIN 2
#define IRC_NICK_OP 4
#define IRC_NICK_HALFOP 8
#define IRC_NICK_VOICE 16
#define IRC_NICK_AWAY 32
#define IRC_NICK_CHANADMIN2 64
#define IRC_NICK_CHANADMIN2 4
#define IRC_NICK_OP 8
#define IRC_NICK_HALFOP 16
#define IRC_NICK_VOICE 32
#define IRC_NICK_AWAY 64
#define IRC_NICK_CHANUSER 128
#define IRC_NICK_SET_FLAG(nick, set, flag) \
if (set) \
@@ -79,6 +79,8 @@ extern void irc_nick_set_away (struct t_irc_channel *channel,
struct t_irc_nick *nick, int is_away);
extern char *irc_nick_as_prefix (struct t_irc_nick *nick, const char *nickname,
const char *force_color);
extern int irc_nick_add_to_infolist (struct t_infolist *infolist,
struct t_irc_nick *nick);
extern void irc_nick_print_log (struct t_irc_nick *nick);
#endif /* irc-nick.h */
+11 -39
View File
@@ -300,11 +300,8 @@ irc_protocol_cmd_join (struct t_irc_server *server, const char *command,
if (!ptr_channel->nicks)
{
if (ptr_channel->topic)
{
free (ptr_channel->topic);
ptr_channel->topic = NULL;
weechat_buffer_set (ptr_channel->buffer, "title", NULL);
}
irc_channel_set_topic (ptr_channel, NULL);
ptr_channel->display_creation_date = 1;
}
@@ -758,11 +755,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
}
}
if (!ptr_channel->topic)
{
ptr_channel->topic = strdup ((host) ? host : "");
weechat_buffer_set (ptr_channel->buffer,
"title", ptr_channel->topic);
}
irc_channel_set_topic (ptr_channel, host);
weechat_printf_tags (ptr_channel->buffer,
tags,
@@ -1058,8 +1051,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
{
char *nick, *host, *pos_args, *pos_end_01, *pos, *pos_message;
char *dcc_args, *pos_file, *pos_addr, *pos_port, *pos_size, *pos_start_resume; /* for DCC */
struct t_plugin_infolist *infolist;
struct t_plugin_infolist_item *item;
struct t_infolist *infolist;
struct t_infolist_item *item;
char plugin_id[128];
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
@@ -1770,12 +1763,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
}
}
if (!ptr_channel->topic)
{
ptr_channel->topic = strdup (host);
weechat_buffer_set (ptr_channel->buffer,
"title", ptr_channel->topic);
}
irc_channel_set_topic (ptr_channel, host);
pos_args += 8;
pos_end_01 = strchr (pos, '\01');
if (pos_end_01)
@@ -1877,11 +1866,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
return WEECHAT_RC_ERROR;
}
}
if (ptr_channel->topic)
free (ptr_channel->topic);
ptr_channel->topic = strdup (host);
weechat_buffer_set (ptr_channel->buffer, "title",
ptr_channel->topic);
irc_channel_set_topic (ptr_channel, host);
weechat_printf_tags (ptr_channel->buffer,
"irc_privmsg,notify_private",
@@ -2112,15 +2097,7 @@ irc_protocol_cmd_topic (struct t_irc_server *server, const char *command,
}
if (ptr_channel)
{
if (ptr_channel->topic)
free (ptr_channel->topic);
if (pos_topic)
ptr_channel->topic = strdup (pos_topic);
else
ptr_channel->topic = strdup ("");
weechat_buffer_set (ptr_channel->buffer, "title", ptr_channel->topic);
}
irc_channel_set_topic (ptr_channel, pos_topic);
return WEECHAT_RC_OK;
}
@@ -3022,12 +2999,7 @@ irc_protocol_cmd_332 (struct t_irc_server *server, const char *command,
ptr_channel = irc_channel_search (server, argv[3]);
if (ptr_channel && ptr_channel->nicks)
{
if (ptr_channel->topic)
free (ptr_channel->topic);
ptr_channel->topic = strdup (pos_topic);
weechat_buffer_set (ptr_channel->buffer, "title", ptr_channel->topic);
}
irc_channel_set_topic (ptr_channel, pos_topic);
weechat_printf_tags ((ptr_channel && ptr_channel->nicks) ?
ptr_channel->buffer : server->buffer,
@@ -3567,7 +3539,7 @@ irc_protocol_cmd_366 (struct t_irc_server *server, const char *command,
int argc, char **argv, char **argv_eol)
{
struct t_irc_channel *ptr_channel;
struct t_plugin_infolist *infolist;
struct t_infolist *infolist;
struct t_config_option *ptr_option;
int num_nicks, num_op, num_halfop, num_voice, num_normal, length, i;
char *string, *prefix;
+108 -11
View File
@@ -227,14 +227,14 @@ irc_server_set_nick (struct t_irc_server *server, const char *nick)
free (server->nick);
server->nick = (nick) ? strdup (nick) : NULL;
weechat_buffer_set (server->buffer, "nick", nick);
weechat_buffer_set (server->buffer, "nick", (void *)nick);
weechat_buffer_set (server->buffer, "highlight_words", nick);
weechat_buffer_set (server->buffer, "highlight_words", (void *)nick);
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
weechat_buffer_set (ptr_channel->buffer, "nick", nick);
weechat_buffer_set (ptr_channel->buffer, "nick", (void *)nick);
}
}
@@ -770,7 +770,7 @@ irc_server_rename (struct t_irc_server *server, const char *new_name)
{
int length;
char *option_name, *name, *pos_option;
struct t_plugin_infolist *infolist;
struct t_infolist *infolist;
struct t_config_option *ptr_option;
/* check if another server exists with this name */
@@ -1765,7 +1765,7 @@ irc_server_connect_cb (void *arg_server, int status)
irc_server_login (server);
server->hook_fd = weechat_hook_fd (server->sock,
1, 0, 0,
irc_server_recv_cb,
&irc_server_recv_cb,
server);
break;
case WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND:
@@ -2353,7 +2353,7 @@ int
irc_server_xfer_send_ready_cb (void *data, const char *signal,
const char *type_data, void *signal_data)
{
struct t_plugin_infolist *infolist;
struct t_infolist *infolist;
struct t_irc_server *server, *ptr_server;
char *plugin_name, *plugin_id, *type, *filename;
int spaces_in_name;
@@ -2363,7 +2363,7 @@ irc_server_xfer_send_ready_cb (void *data, const char *signal,
(void) signal;
(void) type_data;
infolist = (struct t_plugin_infolist *)signal_data;
infolist = (struct t_infolist *)signal_data;
if (weechat_infolist_next (infolist))
{
@@ -2426,7 +2426,7 @@ int
irc_server_xfer_resume_ready_cb (void *data, const char *signal,
const char *type_data, void *signal_data)
{
struct t_plugin_infolist *infolist;
struct t_infolist *infolist;
struct t_irc_server *server, *ptr_server;
char *plugin_name, *plugin_id, *filename;
int spaces_in_name;
@@ -2436,7 +2436,7 @@ irc_server_xfer_resume_ready_cb (void *data, const char *signal,
(void) signal;
(void) type_data;
infolist = (struct t_plugin_infolist *)signal_data;
infolist = (struct t_infolist *)signal_data;
if (weechat_infolist_next (infolist))
{
@@ -2483,7 +2483,7 @@ irc_server_xfer_send_accept_resume_cb (void *data, const char *signal,
const char *type_data,
void *signal_data)
{
struct t_plugin_infolist *infolist;
struct t_infolist *infolist;
struct t_irc_server *server, *ptr_server;
char *plugin_name, *plugin_id, *filename;
int spaces_in_name;
@@ -2493,7 +2493,7 @@ irc_server_xfer_send_accept_resume_cb (void *data, const char *signal,
(void) signal;
(void) type_data;
infolist = (struct t_plugin_infolist *)signal_data;
infolist = (struct t_infolist *)signal_data;
if (weechat_infolist_next (infolist))
{
@@ -2527,6 +2527,103 @@ irc_server_xfer_send_accept_resume_cb (void *data, const char *signal,
return WEECHAT_RC_OK;
}
/*
* irc_server_add_to_infolist: add a server in an infolist
* return 1 if ok, 0 if error
*/
int
irc_server_add_to_infolist (struct t_infolist *infolist,
struct t_irc_server *server)
{
struct t_infolist_item *ptr_item;
if (!infolist || !server)
return 0;
ptr_item = weechat_infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "name", server->name))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "autoconnect", server->autoconnect))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "autoreconnect", server->autoreconnect))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "autoreconnect_delay", server->autoreconnect_delay))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "temp_server", server->temp_server))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "addresses", server->addresses))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "ipv6", server->ipv6))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "ssl", server->ssl))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "password", server->password))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "nicks", server->nicks))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "username", server->username))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "realname", server->realname))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "local_hostname", server->local_hostname))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "command", server->command))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "command_delay", server->command_delay))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "autojoin", server->autojoin))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "autorejoin", server->autorejoin))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "current_address", server->current_address))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "sock", server->sock))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "is_connected", server->is_connected))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "ssl_connected", server->ssl_connected))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "unterminated_message", server->unterminated_message))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "nick", server->nick))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "nick_modes", server->nick_modes))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "prefix", server->prefix))
return 0;
if (!weechat_infolist_new_var_time (ptr_item, "reconnect_start", server->reconnect_start))
return 0;
if (!weechat_infolist_new_var_time (ptr_item, "command_time", server->command_time))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "reconnect_join", server->reconnect_join))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "disable_autojoin", server->disable_autojoin))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "is_away", server->is_away))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "away_message", server->away_message))
return 0;
if (!weechat_infolist_new_var_time (ptr_item, "away_time", server->away_time))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "lag", server->lag))
return 0;
if (!weechat_infolist_new_var_buffer (ptr_item, "lag_check_time", &(server->lag_check_time), sizeof (struct timeval)))
return 0;
if (!weechat_infolist_new_var_time (ptr_item, "lag_next_check", server->lag_next_check))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "queue_msg", server->queue_msg))
return 0;
if (!weechat_infolist_new_var_time (ptr_item, "last_user_message", server->last_user_message))
return 0;
return 1;
}
/*
* irc_server_print_log: print server infos in log (usually for crash dump)
*/
+3
View File
@@ -169,6 +169,7 @@ extern int irc_server_connect (struct t_irc_server *server,
int disable_autojoin);
extern void irc_server_auto_connect (int auto_connect, int temp_server);
extern void irc_server_autojoin_channels ();
extern int irc_server_recv_cb (void *arg_server);
extern int irc_server_timer_cb (void *data);
extern void irc_server_outqueue_free_all (struct t_irc_server *server);
extern int irc_server_get_channel_count (struct t_irc_server *server);
@@ -189,6 +190,8 @@ extern int irc_server_xfer_resume_ready_cb (void *data, const char *signal,
extern int irc_server_xfer_send_accept_resume_cb (void *data, const char *signal,
const char *type_data,
void *signal_data);
extern int irc_server_add_to_infolist (struct t_infolist *infolist,
struct t_irc_server *server);
extern void irc_server_print_log ();
#endif /* irc-server.h */
+303
View File
@@ -0,0 +1,303 @@
/*
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
/* irc-upgrade.c: save/restore IRC plugin data */
#include <string.h>
#include "../weechat-plugin.h"
#include "irc.h"
#include "irc-upgrade.h"
#include "irc-buffer.h"
#include "irc-input.h"
#include "irc-server.h"
#include "irc-channel.h"
#include "irc-nick.h"
struct t_irc_server *irc_upgrade_current_server = NULL;
struct t_irc_channel *irc_upgrade_current_channel = NULL;
/*
* irc_upgrade_save_all_data: save servers/channels/nicks info to upgrade file
*/
int
irc_upgrade_save_all_data (struct t_upgrade_file *upgrade_file)
{
struct t_infolist *infolist;
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
int rc;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
/* save server */
infolist = weechat_infolist_new ();
if (!infolist)
return 0;
if (!irc_server_add_to_infolist (infolist, ptr_server))
{
weechat_infolist_free (infolist);
return 0;
}
rc = weechat_upgrade_write_object (upgrade_file,
IRC_UPGRADE_TYPE_SERVER,
infolist);
weechat_infolist_free (infolist);
if (!rc)
return 0;
for (ptr_channel = ptr_server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
/* save channel */
infolist = weechat_infolist_new ();
if (!infolist)
return 0;
if (!irc_channel_add_to_infolist (infolist, ptr_channel))
{
weechat_infolist_free (infolist);
return 0;
}
rc = weechat_upgrade_write_object (upgrade_file,
IRC_UPGRADE_TYPE_CHANNEL,
infolist);
weechat_infolist_free (infolist);
if (!rc)
return 0;
for (ptr_nick = ptr_channel->nicks; ptr_nick;
ptr_nick = ptr_nick->next_nick)
{
/* save nick */
infolist = weechat_infolist_new ();
if (!infolist)
return 0;
if (!irc_nick_add_to_infolist (infolist, ptr_nick))
{
weechat_infolist_free (infolist);
return 0;
}
rc = weechat_upgrade_write_object (upgrade_file,
IRC_UPGRADE_TYPE_NICK,
infolist);
weechat_infolist_free (infolist);
if (!rc)
return 0;
}
}
}
return 1;
}
/*
* irc_upgrade_save: save upgrade file
* return 1 if ok, 0 if error
*/
int
irc_upgrade_save ()
{
int rc;
struct t_upgrade_file *upgrade_file;
upgrade_file = weechat_upgrade_create (IRC_UPGRADE_FILENAME, 1);
if (!upgrade_file)
return 0;
rc = irc_upgrade_save_all_data (upgrade_file);
weechat_upgrade_close (upgrade_file);
return rc;
}
/*
* irc_upgrade_set_buffer_callbacks: restore buffers callbacks (input and
* close) for buffers created by IRC plugin
*/
void
irc_upgrade_set_buffer_callbacks ()
{
struct t_infolist *infolist;
struct t_gui_buffer *ptr_buffer;
infolist = weechat_infolist_get ("buffer", NULL, NULL);
if (infolist)
{
while (weechat_infolist_next (infolist))
{
if (weechat_infolist_pointer (infolist, "plugin") == weechat_irc_plugin)
{
ptr_buffer = weechat_infolist_pointer (infolist, "pointer");
weechat_buffer_set (ptr_buffer, "close_callback", &irc_buffer_close_cb);
weechat_buffer_set (ptr_buffer, "input_callback", &irc_input_data_cb);
}
}
}
}
/*
* irc_upgrade_read_cb: read callback for
*/
int
irc_upgrade_read_cb (int object_id,
struct t_infolist *infolist)
{
int flags, sock, size;
char *str, *buf;
struct t_irc_nick *ptr_nick;
weechat_infolist_reset_item_cursor (infolist);
while (weechat_infolist_next (infolist))
{
switch (object_id)
{
case IRC_UPGRADE_TYPE_SERVER:
irc_upgrade_current_server = irc_server_search (weechat_infolist_string (infolist, "name"));
if (irc_upgrade_current_server)
{
irc_upgrade_current_server->buffer = weechat_buffer_search (irc_upgrade_current_server->name,
irc_upgrade_current_server->name);
irc_upgrade_current_server->current_address = weechat_infolist_integer (infolist, "current_address");
sock = weechat_infolist_integer (infolist, "sock");
if (sock >= 0)
{
irc_upgrade_current_server->sock = sock;
irc_upgrade_current_server->hook_fd = weechat_hook_fd (irc_upgrade_current_server->sock,
1, 0, 0,
&irc_server_recv_cb,
irc_upgrade_current_server);
}
irc_upgrade_current_server->is_connected = weechat_infolist_integer (infolist, "is_connected");
irc_upgrade_current_server->ssl_connected = weechat_infolist_integer (infolist, "ssl_connected");
str = weechat_infolist_string (infolist, "unterminated_message");
if (str)
irc_upgrade_current_server->unterminated_message = strdup (str);
str = weechat_infolist_string (infolist, "nick");
if (str)
irc_server_set_nick (irc_upgrade_current_server, str);
str = weechat_infolist_string (infolist, "nick_modes");
if (str)
irc_upgrade_current_server->nick_modes = strdup (str);
str = weechat_infolist_string (infolist, "prefix");
if (str)
irc_upgrade_current_server->prefix = strdup (str);
irc_upgrade_current_server->reconnect_start = weechat_infolist_time (infolist, "reconnect_start");
irc_upgrade_current_server->command_time = weechat_infolist_time (infolist, "command_time");
irc_upgrade_current_server->reconnect_join = weechat_infolist_integer (infolist, "reconnect_join");
irc_upgrade_current_server->disable_autojoin = weechat_infolist_integer (infolist, "disable_autojoin");
irc_upgrade_current_server->is_away = weechat_infolist_integer (infolist, "is_away");
str = weechat_infolist_string (infolist, "away_message");
if (str)
irc_upgrade_current_server->away_message = strdup (str);
irc_upgrade_current_server->away_time = weechat_infolist_time (infolist, "away_time");
irc_upgrade_current_server->lag = weechat_infolist_integer (infolist, "lag");
buf = weechat_infolist_buffer (infolist, "lag_check_time", &size);
if (buf)
memcpy (&(irc_upgrade_current_server->lag_check_time), buf, size);
irc_upgrade_current_server->lag_next_check = weechat_infolist_time (infolist, "lag_next_check");
irc_upgrade_current_server->queue_msg = weechat_infolist_integer (infolist, "queue_msg");
irc_upgrade_current_server->last_user_message = weechat_infolist_time (infolist, "last_user_message");
}
break;
case IRC_UPGRADE_TYPE_CHANNEL:
if (irc_upgrade_current_server)
{
irc_upgrade_current_channel = irc_channel_new (irc_upgrade_current_server,
weechat_infolist_integer (infolist, "type"),
weechat_infolist_string (infolist, "name"),
0);
if (irc_upgrade_current_channel)
{
str = weechat_infolist_string (infolist, "topic");
if (str)
irc_channel_set_topic (irc_upgrade_current_channel, str);
str = weechat_infolist_string (infolist, "modes");
if (str)
irc_upgrade_current_channel->modes = strdup (str);
irc_upgrade_current_channel->limit = weechat_infolist_integer (infolist, "limit");
str = weechat_infolist_string (infolist, "key");
if (str)
irc_upgrade_current_channel->key = strdup (str);
irc_upgrade_current_channel->checking_away = weechat_infolist_integer (infolist, "checking_away");
str = weechat_infolist_string (infolist, "away_message");
if (str)
irc_upgrade_current_channel->away_message = strdup (str);
irc_upgrade_current_channel->cycle = weechat_infolist_integer (infolist, "cycle");
irc_upgrade_current_channel->display_creation_date = weechat_infolist_integer (infolist, "display_creation_date");
irc_upgrade_current_channel->nick_completion_reset = weechat_infolist_integer (infolist, "nick_completion_reset");
}
}
break;
case IRC_UPGRADE_TYPE_NICK:
if (irc_upgrade_current_server && irc_upgrade_current_channel)
{
flags = weechat_infolist_integer (infolist, "flags");
ptr_nick = irc_nick_new (irc_upgrade_current_server,
irc_upgrade_current_channel,
weechat_infolist_string (infolist, "name"),
flags & IRC_NICK_CHANOWNER,
flags & IRC_NICK_CHANADMIN,
flags & IRC_NICK_CHANADMIN2,
flags & IRC_NICK_OP,
flags & IRC_NICK_HALFOP,
flags & IRC_NICK_VOICE,
flags & IRC_NICK_CHANUSER);
if (ptr_nick)
{
str = weechat_infolist_string (infolist, "host");
if (str)
ptr_nick->host = strdup (str);
}
}
break;
}
}
return WEECHAT_RC_OK;
}
/*
* irc_upgrade_load: load upgrade file
* return 1 if ok, 0 if error
*/
int
irc_upgrade_load ()
{
int rc;
struct t_upgrade_file *upgrade_file;
irc_upgrade_set_buffer_callbacks ();
upgrade_file = weechat_upgrade_create (IRC_UPGRADE_FILENAME, 0);
rc = weechat_upgrade_read (upgrade_file, &irc_upgrade_read_cb);
return rc;
}
+37
View File
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WEECHAT_IRC_UPGRADE_H
#define __WEECHAT_IRC_UPGRADE_H 1
#define IRC_UPGRADE_FILENAME "irc"
/* For developers: please add new values ONLY AT THE END of enums */
enum t_irc_upgrade_type
{
IRC_UPGRADE_TYPE_SERVER = 0,
IRC_UPGRADE_TYPE_CHANNEL,
IRC_UPGRADE_TYPE_NICK,
};
extern int irc_upgrade_save ();
extern int irc_upgrade_load ();
#endif /* irc-upgrade.h */
+39 -4
View File
@@ -31,6 +31,7 @@
#include "irc-server.h"
#include "irc-channel.h"
#include "irc-nick.h"
#include "irc-upgrade.h"
WEECHAT_PLUGIN_NAME("irc");
@@ -45,6 +46,8 @@ struct t_weechat_plugin *weechat_irc_plugin = NULL;
struct t_hook *irc_hook_timer = NULL;
struct t_hook *irc_hook_timer_check_away = NULL;
int irc_signal_upgrade_received = 0; /* signal "upgrade" received ? */
/*
* irc_signal_quit_cb: callback for "quit" signal
@@ -73,6 +76,25 @@ irc_signal_quit_cb (void *data, const char *signal, const char *type_data,
return WEECHAT_RC_OK;
}
/*
* irc_signal_upgrade_cb: callback for "upgrade" signal
*/
int
irc_signal_upgrade_cb (void *data, const char *signal, const char *type_data,
void *signal_data)
{
/* make C compiler happy */
(void) data;
(void) signal;
(void) type_data;
(void) signal_data;
irc_signal_upgrade_received = 1;
return WEECHAT_RC_OK;
}
/*
* weechat_plugin_init: initialize IRC plugin
*/
@@ -80,7 +102,7 @@ irc_signal_quit_cb (void *data, const char *signal, const char *type_data,
int
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
int i, auto_connect;
int i, auto_connect, upgrading;
weechat_plugin = plugin;
@@ -95,6 +117,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
/* hook some signals */
irc_debug_init ();
weechat_hook_signal ("quit", &irc_signal_quit_cb, NULL);
weechat_hook_signal ("upgrade", &irc_signal_upgrade_cb, NULL);
weechat_hook_signal ("xfer_send_ready", &irc_server_xfer_send_ready_cb, NULL);
weechat_hook_signal ("xfer_resume_ready", &irc_server_xfer_resume_ready_cb, NULL);
weechat_hook_signal ("xfer_send_accept_resume", &irc_server_xfer_send_accept_resume_cb, NULL);
@@ -104,6 +127,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
/* look at arguments */
auto_connect = 1;
upgrading = 0;
for (i = 0; i < argc; i++)
{
if ((weechat_strcasecmp (argv[i], "-a") == 0)
@@ -122,9 +146,16 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
argv[i]);
}
}
else if (weechat_strcasecmp (argv[i], "--upgrade") == 0)
{
upgrading = 1;
}
}
irc_server_auto_connect (auto_connect, 0);
if (upgrading)
irc_upgrade_load ();
else
irc_server_auto_connect (auto_connect, 0);
irc_hook_timer = weechat_hook_timer (1 * 1000, 0, 0,
&irc_server_timer_cb, NULL);
@@ -152,7 +183,11 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
irc_config_write ();
irc_server_disconnect_all ();
if (irc_signal_upgrade_received)
irc_upgrade_save ();
else
irc_server_disconnect_all ();
irc_server_free_all ();
return WEECHAT_RC_OK;
+28 -25
View File
@@ -69,6 +69,8 @@ char *logger_option_time_format = NULL;
int logger_option_info_lines = 0;
int logger_option_backlog = 0;
char *logger_buf_write = NULL; /* buffer for writing a line */
/*
* logger_config_read: read config options for logger plugin
@@ -233,7 +235,7 @@ logger_create_directory ()
char *
logger_get_filename (struct t_gui_buffer *buffer)
{
struct t_plugin_infolist *ptr_infolist;
struct t_infolist *ptr_infolist;
char *res;
char *dir_separator, *weechat_dir, *log_path, *log_path2;
char *plugin_name, *plugin_name2, *category, *category2, *name, *name2;
@@ -326,10 +328,15 @@ logger_write_line (struct t_logger_buffer *logger_buffer,
const char *format, ...)
{
va_list argptr;
char *buf, *charset, *message;
char *charset, *message;
time_t seconds;
struct tm *date_tmp;
char buf_time[256];
if (!logger_buf_write)
logger_buf_write = malloc (LOGGER_BUF_WRITE_SIZE);
if (!logger_buf_write)
return;
if (logger_buffer->log_filename)
{
@@ -347,7 +354,6 @@ logger_write_line (struct t_logger_buffer *logger_buffer,
logger_buffer->log_filename);
free (logger_buffer->log_filename);
logger_buffer->log_filename = NULL;
free (buf);
return;
}
@@ -359,36 +365,30 @@ logger_write_line (struct t_logger_buffer *logger_buffer,
if (date_tmp)
strftime (buf_time, sizeof (buf_time) - 1,
logger_option_time_format, date_tmp);
snprintf (buf, sizeof (buf) - 1,
snprintf (logger_buf_write, LOGGER_BUF_WRITE_SIZE,
_("%s\t**** Beginning of log ****"),
buf_time);
message = (charset) ?
weechat_iconv_from_internal (charset, buf) : NULL;
weechat_iconv_from_internal (charset, logger_buf_write) : NULL;
fprintf (logger_buffer->log_file,
"%s\n", (message) ? message : buf);
"%s\n", (message) ? message : logger_buf_write);
if (message)
free (message);
}
}
buf = malloc (128 * 1024);
if (buf)
{
va_start (argptr, format);
vsnprintf (buf, 128 * 1024, format, argptr);
va_end (argptr);
message = (charset) ?
weechat_iconv_from_internal (charset, buf) : NULL;
fprintf (logger_buffer->log_file,
"%s\n", (message) ? message : buf);
fflush (logger_buffer->log_file);
if (message)
free (message);
free (buf);
}
va_start (argptr, format);
vsnprintf (logger_buf_write, LOGGER_BUF_WRITE_SIZE, format, argptr);
va_end (argptr);
message = (charset) ?
weechat_iconv_from_internal (charset, logger_buf_write) : NULL;
fprintf (logger_buffer->log_file,
"%s\n", (message) ? message : logger_buf_write);
fflush (logger_buffer->log_file);
if (message)
free (message);
}
}
@@ -434,7 +434,7 @@ logger_start_buffer (struct t_gui_buffer *buffer)
void
logger_start_buffer_all ()
{
struct t_plugin_infolist *ptr_infolist;
struct t_infolist *ptr_infolist;
ptr_infolist = weechat_infolist_get ("buffer", NULL, NULL);
if (ptr_infolist)
@@ -767,5 +767,8 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
if (logger_option_time_format)
free (logger_option_time_format);
if (logger_buf_write)
free (logger_buf_write);
return WEECHAT_RC_OK;
}
+2
View File
@@ -24,6 +24,8 @@
#define weechat_plugin weechat_logger_plugin
#define LOGGER_BUF_WRITE_SIZE (16*1024)
extern struct t_weechat_plugin *weechat_logger_plugin;
extern void logger_start_buffer_all ();
+1 -1
View File
@@ -209,7 +209,7 @@ notify_set_buffer (struct t_gui_buffer *buffer)
void
notify_set_buffer_all ()
{
struct t_plugin_infolist *ptr_infolist;
struct t_infolist *ptr_infolist;
ptr_infolist = weechat_infolist_get ("buffer", NULL, NULL);
if (ptr_infolist)
+77 -504
View File
@@ -34,6 +34,7 @@
#include "../core/weechat.h"
#include "../core/wee-config.h"
#include "../core/wee-infolist.h"
#include "../core/wee-input.h"
#include "../core/wee-string.h"
#include "../gui/gui-buffer.h"
@@ -45,7 +46,6 @@
#include "../gui/gui-window.h"
#include "plugin.h"
#include "plugin-config.h"
#include "plugin-infolist.h"
/*
@@ -320,464 +320,16 @@ plugin_api_info_get (struct t_weechat_plugin *plugin, const char *info)
return NULL;
}
/*
* plugin_api_infolist_get_add_buffer: add a buffer in a list
* return 1 if ok, 0 if error
*/
int
plugin_api_infolist_get_add_buffer (struct t_plugin_infolist *infolist,
struct t_gui_buffer *buffer)
{
struct t_plugin_infolist_item *ptr_item;
if (!infolist || !buffer)
return 0;
ptr_item = plugin_infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (!plugin_infolist_new_var_pointer (ptr_item, "pointer", buffer))
return 0;
if (!plugin_infolist_new_var_pointer (ptr_item, "plugin", buffer->plugin))
return 0;
if (!plugin_infolist_new_var_string (ptr_item, "plugin_name",
(buffer->plugin) ?
buffer->plugin->name : NULL))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "number", buffer->number))
return 0;
if (!plugin_infolist_new_var_string (ptr_item, "category", buffer->category))
return 0;
if (!plugin_infolist_new_var_string (ptr_item, "name", buffer->name))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "type", buffer->type))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "notify", buffer->notify))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "num_displayed", buffer->num_displayed))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "lines_hidden", buffer->lines_hidden))
return 0;
if (!plugin_infolist_new_var_string (ptr_item, "title", buffer->title))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "input", buffer->input))
return 0;
if (!plugin_infolist_new_var_string (ptr_item, "input_nick", buffer->input_nick))
return 0;
if (!plugin_infolist_new_var_string (ptr_item, "input_string", buffer->input_buffer))
return 0;
return 1;
}
/*
* plugin_api_infolist_get_add_buffer_line: add a buffer line in a list
* return 1 if ok, 0 if error
*/
int
plugin_api_infolist_get_add_buffer_line (struct t_plugin_infolist *infolist,
struct t_gui_line *line)
{
struct t_plugin_infolist_item *ptr_item;
int i;
char option_name[64];
if (!infolist || !line)
return 0;
ptr_item = plugin_infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (!plugin_infolist_new_var_time (ptr_item, "date", line->date))
return 0;
if (!plugin_infolist_new_var_time (ptr_item, "date_printed", line->date))
return 0;
if (!plugin_infolist_new_var_string (ptr_item, "str_time", line->str_time))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "tags_count", line->tags_count))
return 0;
for (i = 0; i < line->tags_count; i++)
{
snprintf (option_name, sizeof (option_name), "tag_%05d", i + 1);
if (!plugin_infolist_new_var_string (ptr_item, option_name,
line->tags_array[i]))
return 0;
}
if (!plugin_infolist_new_var_integer (ptr_item, "displayed", line->displayed))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "highlight", line->highlight))
return 0;
if (!plugin_infolist_new_var_string (ptr_item, "prefix", line->prefix))
return 0;
if (!plugin_infolist_new_var_string (ptr_item, "message", line->message))
return 0;
return 1;
}
/*
* plugin_api_infolist_get_add_nicklist: add a nicklist
* return 1 if ok, 0 if error
*/
int
plugin_api_infolist_get_add_nicklist (struct t_plugin_infolist *infolist,
struct t_gui_buffer *buffer)
{
struct t_plugin_infolist_item *ptr_item;
struct t_gui_nick_group *ptr_group;
struct t_gui_nick *ptr_nick;
char prefix[2];
if (!infolist || !buffer)
return 0;
ptr_group = NULL;
ptr_nick = NULL;
gui_nicklist_get_next_item (buffer, &ptr_group, &ptr_nick);
while (ptr_group || ptr_nick)
{
ptr_item = plugin_infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (ptr_nick)
{
if (!plugin_infolist_new_var_string (ptr_item, "type", "nick"))
return 0;
if (!plugin_infolist_new_var_string (ptr_item, "name", ptr_nick->name))
return 0;
if (!plugin_infolist_new_var_string (ptr_item, "color", ptr_nick->color))
return 0;
prefix[0] = ptr_nick->prefix;
prefix[1] = '\0';
if (!plugin_infolist_new_var_string (ptr_item, "prefix", prefix))
return 0;
if (!plugin_infolist_new_var_string (ptr_item, "prefix_color", ptr_nick->prefix_color))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "visible", ptr_nick->visible))
return 0;
}
else
{
if (!plugin_infolist_new_var_string (ptr_item, "type", "group"))
return 0;
if (!plugin_infolist_new_var_string (ptr_item, "name", ptr_group->name))
return 0;
if (!plugin_infolist_new_var_string (ptr_item, "color", ptr_group->color))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "visible", ptr_group->visible))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "level", ptr_group->level))
return 0;
}
gui_nicklist_get_next_item (buffer, &ptr_group, &ptr_nick);
}
return 1;
}
/*
* plugin_api_infolist_get_add_window: add a window in a list
* return 1 if ok, 0 if error
*/
int
plugin_api_infolist_get_add_window (struct t_plugin_infolist *infolist,
struct t_gui_window *window)
{
struct t_plugin_infolist_item *ptr_item;
if (!infolist || !window)
return 0;
ptr_item = plugin_infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (!plugin_infolist_new_var_pointer (ptr_item, "pointer", window))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "x", window->win_x))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "y", window->win_y))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "width", window->win_width))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "height", window->win_height))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "width_pct", window->win_width_pct))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "height_pct", window->win_height_pct))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "chat_x", window->win_chat_x))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "chat_y", window->win_chat_y))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "chat_width", window->win_chat_width))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "chat_height", window->win_chat_height))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "nick_x", window->win_nick_x))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "nick_y", window->win_nick_y))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "nick_width", window->win_nick_width))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "nick_height", window->win_nick_height))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "nick_start", window->win_nick_start))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "title_x", window->win_title_x))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "title_y", window->win_title_y))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "title_width", window->win_title_width))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "title_start", window->win_title_start))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "status_x", window->win_status_x))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "status_y", window->win_status_y))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "status_width", window->win_status_width))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "status_height", window->win_status_height))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "input_x", window->win_input_x))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "input_y", window->win_input_y))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "input_width", window->win_input_width))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "input_height", window->win_input_height))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "input_cursor_x", window->win_input_cursor_x))
return 0;
if (!plugin_infolist_new_var_pointer (ptr_item, "buffer", window->buffer))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "start_line_y",
((window->buffer->type == GUI_BUFFER_TYPE_FREE)
&& (window->start_line)) ?
window->start_line->y : 0))
return 0;
return 1;
}
/*
* plugin_api_infolist_get_add_options: add config options in a list
* return 1 if ok, 0 if error
*/
int
plugin_api_infolist_get_add_options (struct t_plugin_infolist *infolist,
const char *option_name)
{
struct t_config_file *ptr_config;
struct t_config_section *ptr_section;
struct t_config_option *ptr_option;
struct t_plugin_infolist_item *ptr_item;
int length;
char *option_full_name, value[128];
if (!infolist)
return 0;
for (ptr_config = config_files; ptr_config;
ptr_config = ptr_config->next_config)
{
for (ptr_section = ptr_config->sections; ptr_section;
ptr_section = ptr_section->next_section)
{
for (ptr_option = ptr_section->options; ptr_option;
ptr_option = ptr_option->next_option)
{
length = strlen (ptr_config->name) + 1 +
strlen (ptr_section->name) + 1 +
strlen (ptr_option->name) + 1;
option_full_name = malloc (length);
if (option_full_name)
{
snprintf (option_full_name, length, "%s.%s.%s",
ptr_config->name,
ptr_section->name,
ptr_option->name);
if (!option_name || !option_name[0]
|| string_match (option_full_name, option_name, 0))
{
ptr_item = plugin_infolist_new_item (infolist);
if (!ptr_item)
{
free (option_full_name);
return 0;
}
if (!plugin_infolist_new_var_string (ptr_item,
"full_name",
option_full_name))
{
free (option_full_name);
return 0;
}
if (!plugin_infolist_new_var_string (ptr_item,
"name",
ptr_option->name))
{
free (option_full_name);
return 0;
}
switch (ptr_option->type)
{
case CONFIG_OPTION_TYPE_BOOLEAN:
if (!plugin_infolist_new_var_string (ptr_item,
"type",
"boolean"))
{
free (option_full_name);
return 0;
}
if (CONFIG_BOOLEAN(ptr_option) == CONFIG_BOOLEAN_TRUE)
snprintf (value, sizeof (value), "on");
else
snprintf (value, sizeof (value), "off");
if (!plugin_infolist_new_var_string (ptr_item,
"value",
value))
{
free (option_full_name);
return 0;
}
if (CONFIG_BOOLEAN_DEFAULT(ptr_option) == CONFIG_BOOLEAN_TRUE)
snprintf (value, sizeof (value), "on");
else
snprintf (value, sizeof (value), "off");
if (!plugin_infolist_new_var_string (ptr_item,
"default_value",
value))
{
free (option_full_name);
return 0;
}
break;
case CONFIG_OPTION_TYPE_INTEGER:
if (!plugin_infolist_new_var_string (ptr_item,
"type",
"integer"))
{
free (option_full_name);
return 0;
}
if (ptr_option->string_values)
{
if (!plugin_infolist_new_var_string (ptr_item,
"value",
ptr_option->string_values[CONFIG_INTEGER(ptr_option)]))
{
free (option_full_name);
return 0;
}
if (!plugin_infolist_new_var_string (ptr_item,
"default_value",
ptr_option->string_values[CONFIG_INTEGER_DEFAULT(ptr_option)]))
{
free (option_full_name);
return 0;
}
}
else
{
snprintf (value, sizeof (value), "%d",
CONFIG_INTEGER(ptr_option));
if (!plugin_infolist_new_var_string (ptr_item,
"value",
value))
{
free (option_full_name);
return 0;
}
snprintf (value, sizeof (value), "%d",
CONFIG_INTEGER_DEFAULT(ptr_option));
if (!plugin_infolist_new_var_string (ptr_item,
"default_value",
value))
{
free (option_full_name);
return 0;
}
}
break;
case CONFIG_OPTION_TYPE_STRING:
if (!plugin_infolist_new_var_string (ptr_item,
"type",
"string"))
{
free (option_full_name);
return 0;
}
if (!plugin_infolist_new_var_string (ptr_item,
"value",
CONFIG_STRING(ptr_option)))
{
free (option_full_name);
return 0;
}
if (!plugin_infolist_new_var_string (ptr_item,
"default_value",
CONFIG_STRING_DEFAULT(ptr_option)))
{
free (option_full_name);
return 0;
}
break;
case CONFIG_OPTION_TYPE_COLOR:
if (!plugin_infolist_new_var_string (ptr_item,
"type",
"color"))
{
free (option_full_name);
return 0;
}
if (!plugin_infolist_new_var_string (ptr_item,
"value",
gui_color_get_name (CONFIG_COLOR(ptr_option))))
{
free (option_full_name);
return 0;
}
if (!plugin_infolist_new_var_string (ptr_item,
"default_value",
gui_color_get_name (CONFIG_COLOR_DEFAULT(ptr_option))))
{
free (option_full_name);
return 0;
}
break;
case CONFIG_NUM_OPTION_TYPES:
break;
}
}
free (option_full_name);
}
}
}
}
return 1;
}
/*
* plugin_api_infolist_get: get list with infos about WeeChat structures
* WARNING: caller has to free string returned
* by this function after use, with weechat_infolist_free()
*/
struct t_plugin_infolist *
struct t_infolist *
plugin_api_infolist_get (const char *name, void *pointer, const char *arguments)
{
struct t_plugin_infolist *ptr_infolist;
struct t_infolist *ptr_infolist;
struct t_gui_buffer *ptr_buffer;
struct t_gui_line *ptr_line;
struct t_gui_window *ptr_window;
@@ -791,15 +343,15 @@ plugin_api_infolist_get (const char *name, void *pointer, const char *arguments)
if (pointer && (!gui_buffer_valid (pointer)))
return NULL;
ptr_infolist = plugin_infolist_new ();
ptr_infolist = infolist_new ();
if (ptr_infolist)
{
if (pointer)
{
/* build list with only one buffer */
if (!plugin_api_infolist_get_add_buffer (ptr_infolist, pointer))
if (!gui_buffer_add_to_infolist (ptr_infolist, pointer))
{
plugin_infolist_free (ptr_infolist);
infolist_free (ptr_infolist);
return NULL;
}
return ptr_infolist;
@@ -810,10 +362,9 @@ plugin_api_infolist_get (const char *name, void *pointer, const char *arguments)
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
if (!plugin_api_infolist_get_add_buffer (ptr_infolist,
ptr_buffer))
if (!gui_buffer_add_to_infolist (ptr_infolist, ptr_buffer))
{
plugin_infolist_free (ptr_infolist);
infolist_free (ptr_infolist);
return NULL;
}
}
@@ -832,16 +383,15 @@ plugin_api_infolist_get (const char *name, void *pointer, const char *arguments)
return NULL;
}
ptr_infolist = plugin_infolist_new ();
ptr_infolist = infolist_new ();
if (ptr_infolist)
{
for (ptr_line = ((struct t_gui_buffer *)pointer)->lines; ptr_line;
ptr_line = ptr_line->next_line)
{
if (!plugin_api_infolist_get_add_buffer_line (ptr_infolist,
ptr_line))
if (!gui_buffer_line_add_to_infolist (ptr_infolist, ptr_line))
{
plugin_infolist_free (ptr_infolist);
infolist_free (ptr_infolist);
return NULL;
}
}
@@ -854,12 +404,12 @@ plugin_api_infolist_get (const char *name, void *pointer, const char *arguments)
if (!pointer || (!gui_buffer_valid (pointer)))
return NULL;
ptr_infolist = plugin_infolist_new ();
ptr_infolist = infolist_new ();
if (ptr_infolist)
{
if (!plugin_api_infolist_get_add_nicklist (ptr_infolist, pointer))
if (!gui_nicklist_add_to_infolist (ptr_infolist, pointer))
{
plugin_infolist_free (ptr_infolist);
infolist_free (ptr_infolist);
return NULL;
}
return ptr_infolist;
@@ -871,15 +421,15 @@ plugin_api_infolist_get (const char *name, void *pointer, const char *arguments)
if (pointer && (!gui_window_valid (pointer)))
return NULL;
ptr_infolist = plugin_infolist_new ();
ptr_infolist = infolist_new ();
if (ptr_infolist)
{
if (pointer)
{
/* build list with only one window */
if (!plugin_api_infolist_get_add_window (ptr_infolist, pointer))
if (!gui_window_add_to_infolist (ptr_infolist, pointer))
{
plugin_infolist_free (ptr_infolist);
infolist_free (ptr_infolist);
return NULL;
}
return ptr_infolist;
@@ -891,10 +441,10 @@ plugin_api_infolist_get (const char *name, void *pointer, const char *arguments)
if ((string_strcasecmp (arguments, "current") == 0)
&& gui_current_window)
{
if (!plugin_api_infolist_get_add_window (ptr_infolist,
gui_current_window))
if (!gui_window_add_to_infolist (ptr_infolist,
gui_current_window))
{
plugin_infolist_free (ptr_infolist);
infolist_free (ptr_infolist);
return NULL;
}
return ptr_infolist;
@@ -907,10 +457,10 @@ plugin_api_infolist_get (const char *name, void *pointer, const char *arguments)
for (ptr_window = gui_windows; ptr_window;
ptr_window = ptr_window->next_window)
{
if (!plugin_api_infolist_get_add_window (ptr_infolist,
ptr_window))
if (!gui_window_add_to_infolist (ptr_infolist,
ptr_window))
{
plugin_infolist_free (ptr_infolist);
infolist_free (ptr_infolist);
return NULL;
}
}
@@ -921,12 +471,12 @@ plugin_api_infolist_get (const char *name, void *pointer, const char *arguments)
}
else if (string_strcasecmp (name, "options") == 0)
{
ptr_infolist = plugin_infolist_new ();
ptr_infolist = infolist_new ();
if (ptr_infolist)
{
if (!plugin_api_infolist_get_add_options (ptr_infolist, arguments))
if (!config_file_add_to_infolist (ptr_infolist, arguments))
{
plugin_infolist_free (ptr_infolist);
infolist_free (ptr_infolist);
return NULL;
}
return ptr_infolist;
@@ -944,12 +494,12 @@ plugin_api_infolist_get (const char *name, void *pointer, const char *arguments)
*/
int
plugin_api_infolist_next (struct t_plugin_infolist *infolist)
plugin_api_infolist_next (struct t_infolist *infolist)
{
if (!infolist || !plugin_infolist_valid (infolist))
if (!infolist || !infolist_valid (infolist))
return 0;
return (plugin_infolist_next_item (infolist)) ? 1 : 0;
return (infolist_next (infolist)) ? 1 : 0;
}
/*
@@ -959,12 +509,25 @@ plugin_api_infolist_next (struct t_plugin_infolist *infolist)
*/
int
plugin_api_infolist_prev (struct t_plugin_infolist *infolist)
plugin_api_infolist_prev (struct t_infolist *infolist)
{
if (!infolist || !plugin_infolist_valid (infolist))
if (!infolist || !infolist_valid (infolist))
return 0;
return (plugin_infolist_prev_item (infolist)) ? 1 : 0;
return (infolist_prev (infolist)) ? 1 : 0;
}
/*
* plugin_api_infolist_reset_item_cursor: reset item cursor in infolist
*/
void
plugin_api_infolist_reset_item_cursor (struct t_infolist *infolist)
{
if (infolist && infolist_valid (infolist))
{
infolist_reset_item_cursor (infolist);
}
}
/*
@@ -972,12 +535,12 @@ plugin_api_infolist_prev (struct t_plugin_infolist *infolist)
*/
char *
plugin_api_infolist_fields (struct t_plugin_infolist *infolist)
plugin_api_infolist_fields (struct t_infolist *infolist)
{
if (!infolist || !plugin_infolist_valid (infolist))
if (!infolist || !infolist_valid (infolist))
return NULL;
return plugin_infolist_get_fields (infolist);
return infolist_fields (infolist);
}
/*
@@ -985,13 +548,12 @@ plugin_api_infolist_fields (struct t_plugin_infolist *infolist)
*/
int
plugin_api_infolist_integer (struct t_plugin_infolist *infolist, const char *var)
plugin_api_infolist_integer (struct t_infolist *infolist, const char *var)
{
if (!infolist || !plugin_infolist_valid (infolist)
|| !((struct t_plugin_infolist *)infolist)->ptr_item)
if (!infolist || !infolist_valid (infolist) || !infolist->ptr_item)
return 0;
return plugin_infolist_get_integer (infolist, var);
return infolist_integer (infolist, var);
}
/*
@@ -999,13 +561,12 @@ plugin_api_infolist_integer (struct t_plugin_infolist *infolist, const char *var
*/
char *
plugin_api_infolist_string (struct t_plugin_infolist *infolist, const char *var)
plugin_api_infolist_string (struct t_infolist *infolist, const char *var)
{
if (!infolist || !plugin_infolist_valid (infolist)
|| !((struct t_plugin_infolist *)infolist)->ptr_item)
if (!infolist || !infolist_valid (infolist) || !infolist->ptr_item)
return NULL;
return plugin_infolist_get_string (infolist, var);
return infolist_string (infolist, var);
}
/*
@@ -1013,13 +574,26 @@ plugin_api_infolist_string (struct t_plugin_infolist *infolist, const char *var)
*/
void *
plugin_api_infolist_pointer (struct t_plugin_infolist *infolist, const char *var)
plugin_api_infolist_pointer (struct t_infolist *infolist, const char *var)
{
if (!infolist || !plugin_infolist_valid (infolist)
|| !((struct t_plugin_infolist *)infolist)->ptr_item)
if (!infolist || !infolist_valid (infolist) || !infolist->ptr_item)
return NULL;
return plugin_infolist_get_pointer (infolist, var);
return infolist_pointer (infolist, var);
}
/*
* plugin_api_infolist_buffer: get a buffer variable value in current list item
*/
void *
plugin_api_infolist_buffer (struct t_infolist *infolist, const char *var,
int *size)
{
if (!infolist || !infolist_valid (infolist) || !infolist->ptr_item)
return NULL;
return infolist_buffer (infolist, var, size);
}
/*
@@ -1027,13 +601,12 @@ plugin_api_infolist_pointer (struct t_plugin_infolist *infolist, const char *var
*/
time_t
plugin_api_infolist_time (struct t_plugin_infolist *infolist, const char *var)
plugin_api_infolist_time (struct t_infolist *infolist, const char *var)
{
if (!infolist || !plugin_infolist_valid (infolist)
|| !((struct t_plugin_infolist *)infolist)->ptr_item)
if (!infolist || !infolist_valid (infolist) || !infolist->ptr_item)
return 0;
return plugin_infolist_get_time (infolist, var);
return infolist_time (infolist, var);
}
/*
@@ -1041,8 +614,8 @@ plugin_api_infolist_time (struct t_plugin_infolist *infolist, const char *var)
*/
void
plugin_api_infolist_free (struct t_plugin_infolist *infolist)
plugin_api_infolist_free (struct t_infolist *infolist)
{
if (infolist && plugin_infolist_valid (infolist))
plugin_infolist_free (infolist);
if (infolist && infolist_valid (infolist))
infolist_free (infolist);
}
+14 -11
View File
@@ -50,20 +50,23 @@ extern void plugin_api_command (struct t_weechat_plugin *plugin,
extern char *plugin_api_info_get (struct t_weechat_plugin *plugin, const char *info);
/* infolists */
extern struct t_plugin_infolist *plugin_api_infolist_get (const char *name,
void *pointer,
const char *arguments);
extern int plugin_api_infolist_next (struct t_plugin_infolist *infolist);
extern int plugin_api_infolist_prev (struct t_plugin_infolist *infolist);
extern char *plugin_api_infolist_fields (struct t_plugin_infolist *infolist);
extern int plugin_api_infolist_integer (struct t_plugin_infolist *infolist,
extern struct t_infolist *plugin_api_infolist_get (const char *name,
void *pointer,
const char *arguments);
extern int plugin_api_infolist_next (struct t_infolist *infolist);
extern int plugin_api_infolist_prev (struct t_infolist *infolist);
extern void plugin_api_infolist_reset_item_cursor (struct t_infolist *infolist);
extern char *plugin_api_infolist_fields (struct t_infolist *infolist);
extern int plugin_api_infolist_integer (struct t_infolist *infolist,
const char *var);
extern char *plugin_api_infolist_string (struct t_plugin_infolist *infolist,
extern char *plugin_api_infolist_string (struct t_infolist *infolist,
const char *var);
extern void *plugin_api_infolist_pointer (struct t_plugin_infolist *infolist,
extern void *plugin_api_infolist_pointer (struct t_infolist *infolist,
const char *var);
extern time_t plugin_api_infolist_time (struct t_plugin_infolist *infolist,
extern void *plugin_api_infolist_buffer (struct t_infolist *infolist,
const char *var, int *size);
extern time_t plugin_api_infolist_time (struct t_infolist *infolist,
const char *var);
extern void plugin_api_infolist_free (struct t_plugin_infolist *infolist);
extern void plugin_api_infolist_free (struct t_infolist *infolist);
#endif /* plugin-api.h */
-616
View File
@@ -1,616 +0,0 @@
/*
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
/* plugin-infolist.c: manages plugin info lists */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include "../core/weechat.h"
#include "../core/wee-log.h"
#include "../core/wee-string.h"
#include "plugin-infolist.h"
struct t_plugin_infolist *plugin_infolists = NULL;
struct t_plugin_infolist *last_plugin_infolist = NULL;
/*
* plugin_list_new: create a new plugin list
*/
struct t_plugin_infolist *
plugin_infolist_new ()
{
struct t_plugin_infolist *new_infolist;
new_infolist = malloc (sizeof (*new_infolist));
if (new_infolist)
{
new_infolist->items = NULL;
new_infolist->last_item = NULL;
new_infolist->ptr_item = NULL;
new_infolist->prev_infolist = last_plugin_infolist;
new_infolist->next_infolist = NULL;
if (plugin_infolists)
last_plugin_infolist->next_infolist = new_infolist;
else
plugin_infolists = new_infolist;
last_plugin_infolist = new_infolist;
}
return new_infolist;
}
/*
* plugin_infolist_new_item: create a new item in a plugin list
*/
struct t_plugin_infolist_item *
plugin_infolist_new_item (struct t_plugin_infolist *list)
{
struct t_plugin_infolist_item *new_item;
new_item = malloc (sizeof (*new_item));
if (new_item)
{
new_item->vars = NULL;
new_item->last_var = NULL;
new_item->fields = NULL;
new_item->prev_item = list->last_item;
new_item->next_item = NULL;
if (list->items)
list->last_item->next_item = new_item;
else
list->items = new_item;
list->last_item = new_item;
}
return new_item;
}
/*
* plugin_infolist_new_var_integer: create a new integer variable in an item
*/
struct t_plugin_infolist_var *
plugin_infolist_new_var_integer (struct t_plugin_infolist_item *item,
const char *name, int value)
{
struct t_plugin_infolist_var *new_var;
if (!item || !name || !name[0])
return NULL;
new_var = malloc (sizeof (*new_var));
if (new_var)
{
new_var->name = strdup (name);
new_var->type = PLUGIN_INFOLIST_INTEGER;
new_var->value = malloc (sizeof (int));
if (new_var->value)
*((int *)new_var->value) = value;
new_var->prev_var = item->last_var;
new_var->next_var = NULL;
if (item->vars)
item->last_var->next_var = new_var;
else
item->vars = new_var;
item->last_var = new_var;
}
return new_var;
}
/*
* plugin_infolist_new_var_string: create a new string variable in an item
*/
struct t_plugin_infolist_var *
plugin_infolist_new_var_string (struct t_plugin_infolist_item *item,
const char *name, const char *value)
{
struct t_plugin_infolist_var *new_var;
if (!item || !name || !name[0])
return NULL;
new_var = malloc (sizeof (*new_var));
if (new_var)
{
new_var->name = strdup (name);
new_var->type = PLUGIN_INFOLIST_STRING;
new_var->value = (value) ? strdup (value) : NULL;
new_var->prev_var = item->last_var;
new_var->next_var = NULL;
if (item->vars)
item->last_var->next_var = new_var;
else
item->vars = new_var;
item->last_var = new_var;
}
return new_var;
}
/*
* plugin_infolist_new_var_pointer: create a new pointer variable in an item
*/
struct t_plugin_infolist_var *
plugin_infolist_new_var_pointer (struct t_plugin_infolist_item *item,
const char *name, void *pointer)
{
struct t_plugin_infolist_var *new_var;
if (!item || !name || !name[0])
return NULL;
new_var = malloc (sizeof (*new_var));
if (new_var)
{
new_var->name = strdup (name);
new_var->type = PLUGIN_INFOLIST_POINTER;
new_var->value = pointer;
new_var->prev_var = item->last_var;
new_var->next_var = NULL;
if (item->vars)
item->last_var->next_var = new_var;
else
item->vars = new_var;
item->last_var = new_var;
}
return new_var;
}
/*
* plugin_infolist_new_var_time: create a new time variable in an item
*/
struct t_plugin_infolist_var *
plugin_infolist_new_var_time (struct t_plugin_infolist_item *item,
const char *name, time_t time)
{
struct t_plugin_infolist_var *new_var;
if (!item || !name || !name[0])
return NULL;
new_var = malloc (sizeof (*new_var));
if (new_var)
{
new_var->name = strdup (name);
new_var->type = PLUGIN_INFOLIST_TIME;
new_var->value = malloc (sizeof (time_t));
if (new_var->value)
*((time_t *)new_var->value) = time;
new_var->prev_var = item->last_var;
new_var->next_var = NULL;
if (item->vars)
item->last_var->next_var = new_var;
else
item->vars = new_var;
item->last_var = new_var;
}
return new_var;
}
/*
* plugin_infolist_valid: check if a list pointer exists
* return 1 if list exists
* 0 if list is not found
*/
int
plugin_infolist_valid (struct t_plugin_infolist *list)
{
struct t_plugin_infolist *ptr_infolist;
for (ptr_infolist = plugin_infolists; ptr_infolist;
ptr_infolist = ptr_infolist->next_infolist)
{
if (ptr_infolist == list)
return 1;
}
/* list not found */
return 0;
}
/*
* plugin_infolist_next_item: return next item for a list
* if current item pointer is NULL,
* then return first item of list
*/
struct t_plugin_infolist_item *
plugin_infolist_next_item (struct t_plugin_infolist *list)
{
if (!list->ptr_item)
{
list->ptr_item = list->items;
return list->ptr_item;
}
list->ptr_item = list->ptr_item->next_item;
return list->ptr_item;
}
/*
* plugin_infolist_prev_item: return previous item for a list
* if current item pointer is NULL,
* then return last item of list
*/
struct t_plugin_infolist_item *
plugin_infolist_prev_item (struct t_plugin_infolist *list)
{
if (!list->ptr_item)
{
list->ptr_item = list->last_item;
return list->ptr_item;
}
list->ptr_item = list->ptr_item->prev_item;
return list->ptr_item;
}
/*
* plugin_infolist_get_fields: get list of fields for current list item
*/
char *
plugin_infolist_get_fields (struct t_plugin_infolist *list)
{
struct t_plugin_infolist_var *ptr_var;
int length;
if (!list || !list->ptr_item)
return NULL;
/* list of fields already asked ? if yes, just return string */
if (list->ptr_item->fields)
return list->ptr_item->fields;
length = 0;
for (ptr_var = list->ptr_item->vars; ptr_var; ptr_var = ptr_var->next_var)
{
length += strlen (ptr_var->name) + 3;
}
list->ptr_item->fields = malloc (length + 1);
if (!list->ptr_item->fields)
return NULL;
list->ptr_item->fields[0] = '\0';
for (ptr_var = list->ptr_item->vars; ptr_var; ptr_var = ptr_var->next_var)
{
switch (ptr_var->type)
{
case PLUGIN_INFOLIST_INTEGER:
strcat (list->ptr_item->fields, "i:");
break;
case PLUGIN_INFOLIST_STRING:
strcat (list->ptr_item->fields, "s:");
break;
case PLUGIN_INFOLIST_POINTER:
strcat (list->ptr_item->fields, "p:");
break;
case PLUGIN_INFOLIST_TIME:
strcat (list->ptr_item->fields, "t:");
break;
}
strcat (list->ptr_item->fields, ptr_var->name);
if (ptr_var->next_var)
strcat (list->ptr_item->fields, ",");
}
return list->ptr_item->fields;
}
/*
* plugin_infolist_get_integer: get an integer variable value in current list item
*/
int
plugin_infolist_get_integer (struct t_plugin_infolist *list, const char *var)
{
struct t_plugin_infolist_var *ptr_var;
if (!list || !list->ptr_item || !var || !var[0])
return 0;
for (ptr_var = list->ptr_item->vars; ptr_var; ptr_var = ptr_var->next_var)
{
if (string_strcasecmp (ptr_var->name, var) == 0)
{
if (ptr_var->type == PLUGIN_INFOLIST_INTEGER)
return *((int *)ptr_var->value);
else
return 0;
}
}
/* variable not found */
return 0;
}
/*
* plugin_infolist_get_string: get a string variable value in current list item
*/
char *
plugin_infolist_get_string (struct t_plugin_infolist *list, const char *var)
{
struct t_plugin_infolist_var *ptr_var;
if (!list || !list->ptr_item || !var || !var[0])
return NULL;
for (ptr_var = list->ptr_item->vars; ptr_var; ptr_var = ptr_var->next_var)
{
if (string_strcasecmp (ptr_var->name, var) == 0)
{
if (ptr_var->type == PLUGIN_INFOLIST_STRING)
return (char *)ptr_var->value;
else
return NULL;
}
}
/* variable not found */
return NULL;
}
/*
* plugin_infolist_get_pointer: get a pointer variable value in current list item
*/
void *
plugin_infolist_get_pointer (struct t_plugin_infolist *list, const char *var)
{
struct t_plugin_infolist_var *ptr_var;
if (!list || !list->ptr_item || !var || !var[0])
return NULL;
for (ptr_var = list->ptr_item->vars; ptr_var; ptr_var = ptr_var->next_var)
{
if (string_strcasecmp (ptr_var->name, var) == 0)
{
if (ptr_var->type == PLUGIN_INFOLIST_POINTER)
return ptr_var->value;
else
return NULL;
}
}
/* variable not found */
return NULL;
}
/*
* plugin_infolist_get_time: get a time variable value in current list item
*/
time_t
plugin_infolist_get_time (struct t_plugin_infolist *list, const char *var)
{
struct t_plugin_infolist_var *ptr_var;
if (!list || !list->ptr_item || !var || !var[0])
return 0;
for (ptr_var = list->ptr_item->vars; ptr_var; ptr_var = ptr_var->next_var)
{
if (string_strcasecmp (ptr_var->name, var) == 0)
{
if (ptr_var->type == PLUGIN_INFOLIST_TIME)
return *((time_t *)ptr_var->value);
else
return 0;
}
}
/* variable not found */
return 0;
}
/*
* plugin_infolist_var_free: free a plugin list variable
*/
void
plugin_infolist_var_free (struct t_plugin_infolist_item *item,
struct t_plugin_infolist_var *var)
{
struct t_plugin_infolist_var *new_vars;
/* remove var */
if (item->last_var == var)
item->last_var = var->prev_var;
if (var->prev_var)
{
(var->prev_var)->next_var = var->next_var;
new_vars = item->vars;
}
else
new_vars = var->next_var;
if (var->next_var)
(var->next_var)->prev_var = var->prev_var;
/* free data */
if (var->name)
free (var->name);
if (((var->type == PLUGIN_INFOLIST_INTEGER)
|| (var->type == PLUGIN_INFOLIST_STRING)
|| (var->type == PLUGIN_INFOLIST_TIME))
&& var->value)
{
free (var->value);
}
free (var);
item->vars = new_vars;
}
/*
* plugin_infolist_item_free: free a plugin list item
*/
void
plugin_infolist_item_free (struct t_plugin_infolist *list,
struct t_plugin_infolist_item *item)
{
struct t_plugin_infolist_item *new_items;
/* remove var */
if (list->last_item == item)
list->last_item = item->prev_item;
if (item->prev_item)
{
(item->prev_item)->next_item = item->next_item;
new_items = list->items;
}
else
new_items = item->next_item;
if (item->next_item)
(item->next_item)->prev_item = item->prev_item;
/* free data */
while (item->vars)
{
plugin_infolist_var_free (item, item->vars);
}
if (item->fields)
free (item->fields);
free (item);
list->items = new_items;
}
/*
* plugin_infolist_free: free a plugin list
*/
void
plugin_infolist_free (struct t_plugin_infolist *list)
{
struct t_plugin_infolist *new_plugin_infolists;
/* remove list */
if (last_plugin_infolist == list)
last_plugin_infolist = list->prev_infolist;
if (list->prev_infolist)
{
(list->prev_infolist)->next_infolist = list->next_infolist;
new_plugin_infolists = plugin_infolists;
}
else
new_plugin_infolists = list->next_infolist;
if (list->next_infolist)
(list->next_infolist)->prev_infolist = list->prev_infolist;
/* free data */
while (list->items)
{
plugin_infolist_item_free (list, list->items);
}
free (list);
plugin_infolists = new_plugin_infolists;
}
/*
* plugin_infolist_print_log: print plugin lists infos in log (usually for crash dump)
*/
void
plugin_infolist_print_log ()
{
struct t_plugin_infolist *ptr_infolist;
struct t_plugin_infolist_item *ptr_item;
struct t_plugin_infolist_var *ptr_var;
for (ptr_infolist = plugin_infolists; ptr_infolist;
ptr_infolist = ptr_infolist->next_infolist)
{
log_printf ("");
log_printf ("[plugin infolist (addr:0x%x)]", ptr_infolist);
log_printf (" items. . . . . . . . . : 0x%x", ptr_infolist->items);
log_printf (" last_item. . . . . . . : 0x%x", ptr_infolist->last_item);
log_printf (" ptr_item . . . . . . . : 0x%x", ptr_infolist->ptr_item);
log_printf (" prev_infolist. . . . . : 0x%x", ptr_infolist->prev_infolist);
log_printf (" next_infolist. . . . . : 0x%x", ptr_infolist->next_infolist);
for (ptr_item = ptr_infolist->items; ptr_item;
ptr_item = ptr_item->next_item)
{
log_printf ("");
log_printf (" [item (addr:0x%x)]", ptr_item);
log_printf (" vars . . . . . . . . . : 0x%x", ptr_item->vars);
log_printf (" last_var . . . . . . . : 0x%x", ptr_item->last_var);
log_printf (" prev_item. . . . . . . : 0x%x", ptr_item->prev_item);
log_printf (" next_item. . . . . . . : 0x%x", ptr_item->next_item);
for (ptr_var = ptr_item->vars; ptr_var;
ptr_var = ptr_var->next_var)
{
log_printf ("");
log_printf (" [var (addr:0x%x)]", ptr_var);
log_printf (" name . . . . . . . . : '%s'", ptr_var->name);
log_printf (" type . . . . . . . . : %d", ptr_var->type);
switch (ptr_var->type)
{
case PLUGIN_INFOLIST_INTEGER:
log_printf (" value (integer). . . : %d", *((int *)ptr_var->value));
break;
case PLUGIN_INFOLIST_STRING:
log_printf (" value (string) . . . : '%s'", (char *)ptr_var->value);
break;
case PLUGIN_INFOLIST_POINTER:
log_printf (" value (pointer). . . : 0x%x", ptr_var->value);
break;
case PLUGIN_INFOLIST_TIME:
log_printf (" value (time) . . . . : %ld", *((time_t *)ptr_var->value));
break;
}
log_printf (" prev_var . . . . . . : 0x%x", ptr_var->prev_var);
log_printf (" next_var . . . . . . : 0x%x", ptr_var->next_var);
}
}
}
}
-97
View File
@@ -1,97 +0,0 @@
/*
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WEECHAT_PLUGIN_INFOLIST_H
#define __WEECHAT_PLUGIN_INFOLIST_H 1
/* list structures */
enum t_plugin_infolist_type
{
PLUGIN_INFOLIST_INTEGER = 0,
PLUGIN_INFOLIST_STRING,
PLUGIN_INFOLIST_POINTER,
PLUGIN_INFOLIST_TIME,
};
struct t_plugin_infolist_var
{
char *name; /* variable name */
enum t_plugin_infolist_type type; /* type: integer, string, time */
void *value; /* pointer to value */
struct t_plugin_infolist_var *prev_var; /* link to previous variable */
struct t_plugin_infolist_var *next_var; /* link to next variable */
};
struct t_plugin_infolist_item
{
struct t_plugin_infolist_var *vars; /* item variables */
struct t_plugin_infolist_var *last_var; /* last variable */
char *fields; /* fields list (NULL if never */
/* asked) */
struct t_plugin_infolist_item *prev_item; /* link to previous item */
struct t_plugin_infolist_item *next_item; /* link to next item */
};
struct t_plugin_infolist
{
struct t_plugin_infolist_item *items; /* link to items */
struct t_plugin_infolist_item *last_item; /* last variable */
struct t_plugin_infolist_item *ptr_item; /* pointer to current item */
struct t_plugin_infolist *prev_infolist; /* link to previous list */
struct t_plugin_infolist *next_infolist; /* link to next list */
};
/* list variables */
extern struct t_plugin_infolist *plugin_infolists;
extern struct t_plugin_infolist *last_plugin_infolist;
/* list functions */
extern struct t_plugin_infolist *plugin_infolist_new ();
extern struct t_plugin_infolist_item *plugin_infolist_new_item (struct t_plugin_infolist *list);
extern struct t_plugin_infolist_var *plugin_infolist_new_var_integer (struct t_plugin_infolist_item *item,
const char *name,
int value);
extern struct t_plugin_infolist_var *plugin_infolist_new_var_string (struct t_plugin_infolist_item *item,
const char *name,
const char *value);
extern struct t_plugin_infolist_var *plugin_infolist_new_var_pointer (struct t_plugin_infolist_item *item,
const char *name,
void *pointer);
extern struct t_plugin_infolist_var *plugin_infolist_new_var_time (struct t_plugin_infolist_item *item,
const char *name,
time_t time);
extern int plugin_infolist_valid (struct t_plugin_infolist *list);
extern struct t_plugin_infolist_item *plugin_infolist_next_item (struct t_plugin_infolist *list);
extern struct t_plugin_infolist_item *plugin_infolist_prev_item (struct t_plugin_infolist *list);
extern char *plugin_infolist_get_fields (struct t_plugin_infolist *list);
extern int plugin_infolist_get_integer (struct t_plugin_infolist *list,
const char *var);
extern char *plugin_infolist_get_string (struct t_plugin_infolist *list,
const char *var);
extern void *plugin_infolist_get_pointer (struct t_plugin_infolist *list,
const char *var);
extern time_t plugin_infolist_get_time (struct t_plugin_infolist *list,
const char *var);
extern void plugin_infolist_free (struct t_plugin_infolist *list);
extern void plugin_infolist_print_log ();
#endif /* plugin-infolist.h */
+25 -10
View File
@@ -36,10 +36,12 @@
#include "../core/weechat.h"
#include "../core/wee-config.h"
#include "../core/wee-hook.h"
#include "../core/wee-infolist.h"
#include "../core/wee-list.h"
#include "../core/wee-log.h"
#include "../core/wee-network.h"
#include "../core/wee-string.h"
#include "../core/wee-upgrade-file.h"
#include "../core/wee-utf8.h"
#include "../core/wee-util.h"
#include "../gui/gui-bar.h"
@@ -50,7 +52,6 @@
#include "plugin.h"
#include "plugin-api.h"
#include "plugin-config.h"
#include "plugin-infolist.h"
struct t_weechat_plugin *weechat_plugins = NULL;
@@ -69,6 +70,9 @@ plugin_search (const char *name)
{
struct t_weechat_plugin *ptr_plugin;
if (!name)
return NULL;
for (ptr_plugin = weechat_plugins; ptr_plugin;
ptr_plugin = ptr_plugin->next_plugin)
{
@@ -417,22 +421,30 @@ plugin_load (const char *filename)
new_plugin->network_connect_to = &network_connect_to;
new_plugin->info_get = &plugin_api_info_get;
new_plugin->infolist_new = &plugin_infolist_new;
new_plugin->infolist_new_item = &plugin_infolist_new_item;
new_plugin->infolist_new_var_integer = &plugin_infolist_new_var_integer;
new_plugin->infolist_new_var_string = &plugin_infolist_new_var_string;
new_plugin->infolist_new_var_pointer = &plugin_infolist_new_var_pointer;
new_plugin->infolist_new_var_time = &plugin_infolist_new_var_time;
new_plugin->infolist_new = &infolist_new;
new_plugin->infolist_new_item = &infolist_new_item;
new_plugin->infolist_new_var_integer = &infolist_new_var_integer;
new_plugin->infolist_new_var_string = &infolist_new_var_string;
new_plugin->infolist_new_var_pointer = &infolist_new_var_pointer;
new_plugin->infolist_new_var_buffer = &infolist_new_var_buffer;
new_plugin->infolist_new_var_time = &infolist_new_var_time;
new_plugin->infolist_get = &plugin_api_infolist_get;
new_plugin->infolist_next = &plugin_api_infolist_next;
new_plugin->infolist_prev = &plugin_api_infolist_prev;
new_plugin->infolist_reset_item_cursor = &plugin_api_infolist_reset_item_cursor;
new_plugin->infolist_fields = &plugin_api_infolist_fields;
new_plugin->infolist_integer = &plugin_api_infolist_integer;
new_plugin->infolist_string = &plugin_api_infolist_string;
new_plugin->infolist_pointer = &plugin_api_infolist_pointer;
new_plugin->infolist_buffer = &plugin_api_infolist_buffer;
new_plugin->infolist_time = &plugin_api_infolist_time;
new_plugin->infolist_free = &plugin_api_infolist_free;
new_plugin->upgrade_create = &upgrade_file_create;
new_plugin->upgrade_write_object = &upgrade_file_write_object;
new_plugin->upgrade_read = &upgrade_file_read;
new_plugin->upgrade_close = &upgrade_file_close;
/* add new plugin to list */
new_plugin->prev_plugin = last_weechat_plugin;
@@ -443,6 +455,10 @@ plugin_load (const char *filename)
weechat_plugins = new_plugin;
last_weechat_plugin = new_plugin;
/* associate orphan buffers with this plugin (if asked during upgrade
process) */
gui_buffer_set_plugin_for_upgrade (name, new_plugin);
/* build arguments for plugin */
argc = 0;
argv = NULL;
@@ -456,6 +472,7 @@ plugin_load (const char *filename)
{
if ((string_strcasecmp (plugin_argv[i], "-a") == 0)
|| (string_strcasecmp (plugin_argv[i], "--no-connect") == 0)
|| (string_strcasecmp (plugin_argv[i], "--upgrade") == 0)
|| (string_strncasecmp (plugin_argv[i], name, strlen (name)) == 0))
{
argv[argc] = plugin_argv[i];
@@ -841,6 +858,4 @@ plugin_print_log ()
log_printf (" prev_plugin. . . . . . : 0x%x", ptr_plugin->prev_plugin);
log_printf (" next_plugin. . . . . . : 0x%x", ptr_plugin->next_plugin);
}
plugin_infolist_print_log ();
}
+2 -2
View File
@@ -3488,7 +3488,7 @@ weechat_lua_api_buffer_set (lua_State *L)
property = lua_tostring (lua_current_interpreter, -2);
value = lua_tostring (lua_current_interpreter, -1);
weechat_buffer_set (script_str2ptr (buffer), property, value);
weechat_buffer_set (script_str2ptr (buffer), property, (void *)value);
LUA_RETURN_OK;
}
@@ -4147,7 +4147,7 @@ weechat_lua_api_bar_set (lua_State *L)
weechat_buffer_set (script_str2ptr (bar),
property,
value);
(void *)value);
LUA_RETURN_OK;
}
+71 -33
View File
@@ -386,7 +386,7 @@ struct t_weechat_plugin
char *(*buffer_get_string) (struct t_gui_buffer *buffer, const char *property);
void *(*buffer_get_pointer) (struct t_gui_buffer *buffer, const char *property);
void (*buffer_set) (struct t_gui_buffer *buffer, const char *property,
const char *value);
void *value);
/* nicklist */
struct t_gui_nick_group *(*nicklist_add_group) (struct t_gui_buffer *buffer,
@@ -455,30 +455,48 @@ struct t_weechat_plugin
char *(*info_get) (struct t_weechat_plugin *plugin, const char *info);
/* infolists */
struct t_plugin_infolist *(*infolist_new) ();
struct t_plugin_infolist_item *(*infolist_new_item) (struct t_plugin_infolist *list);
struct t_plugin_infolist_var *(*infolist_new_var_integer) (struct t_plugin_infolist_item *item,
const char *name,
int value);
struct t_plugin_infolist_var *(*infolist_new_var_string) (struct t_plugin_infolist_item *item,
const char *name,
const char *value);
struct t_plugin_infolist_var *(*infolist_new_var_pointer) (struct t_plugin_infolist_item *item,
const char *name,
void *pointer);
struct t_plugin_infolist_var *(*infolist_new_var_time) (struct t_plugin_infolist_item *item,
const char *name,
time_t time);
struct t_plugin_infolist *(*infolist_get) (const char *name, void *pointer,
const char *arguments);
int (*infolist_next) (struct t_plugin_infolist *infolist);
int (*infolist_prev) (struct t_plugin_infolist *infolist);
char *(*infolist_fields) (struct t_plugin_infolist *infolist);
int (*infolist_integer) (struct t_plugin_infolist *infolist, const char *var);
char *(*infolist_string) (struct t_plugin_infolist *infolist, const char *var);
void *(*infolist_pointer) (struct t_plugin_infolist *infolist, const char *var);
time_t (*infolist_time) (struct t_plugin_infolist *infolist, const char *var);
void (*infolist_free) (struct t_plugin_infolist *infolist);
struct t_infolist *(*infolist_new) ();
struct t_infolist_item *(*infolist_new_item) (struct t_infolist *infolist);
struct t_infolist_var *(*infolist_new_var_integer) (struct t_infolist_item *item,
const char *name,
int value);
struct t_infolist_var *(*infolist_new_var_string) (struct t_infolist_item *item,
const char *name,
const char *value);
struct t_infolist_var *(*infolist_new_var_pointer) (struct t_infolist_item *item,
const char *name,
void *pointer);
struct t_infolist_var *(*infolist_new_var_buffer) (struct t_infolist_item *item,
const char *name,
void *pointer,
int size);
struct t_infolist_var *(*infolist_new_var_time) (struct t_infolist_item *item,
const char *name,
time_t time);
struct t_infolist *(*infolist_get) (const char *name, void *pointer,
const char *arguments);
int (*infolist_next) (struct t_infolist *infolist);
int (*infolist_prev) (struct t_infolist *infolist);
void (*infolist_reset_item_cursor) (struct t_infolist *infolist);
char *(*infolist_fields) (struct t_infolist *infolist);
int (*infolist_integer) (struct t_infolist *infolist, const char *var);
char *(*infolist_string) (struct t_infolist *infolist, const char *var);
void *(*infolist_pointer) (struct t_infolist *infolist, const char *var);
void *(*infolist_buffer) (struct t_infolist *infolist, const char *var,
int *size);
time_t (*infolist_time) (struct t_infolist *infolist, const char *var);
void (*infolist_free) (struct t_infolist *infolist);
/* upgrade */
struct t_upgrade_file *(*upgrade_create) (const char *filename,
int write);
int (*upgrade_write_object) (struct t_upgrade_file *upgrade_file,
int object_id,
struct t_infolist *infolist);
int (*upgrade_read) (struct t_upgrade_file *upgrade_file,
int (*callback_read)(int object_id,
struct t_infolist *infolist));
void (*upgrade_close) (struct t_upgrade_file *upgrade_file);
/* WeeChat developers: ALWAYS add new functions at the end */
};
@@ -905,25 +923,45 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->infolist_new_var_string(__item, __name, __value)
#define weechat_infolist_new_var_pointer(__item, __name, __pointer) \
weechat_plugin->infolist_new_var_pointer(__item, __name, __pointer)
#define weechat_infolist_new_var_buffer(__item, __name, __buffer, \
__size) \
weechat_plugin->infolist_new_var_buffer(__item, __name, __buffer, \
__size)
#define weechat_infolist_new_var_time(__item, __name, __time) \
weechat_plugin->infolist_new_var_time(__item, __name, __time)
#define weechat_infolist_get(__name, __pointer, __arguments) \
weechat_plugin->infolist_get(__name, __pointer, __arguments)
#define weechat_infolist_next(__list) \
#define weechat_infolist_next(__list) \
weechat_plugin->infolist_next(__list)
#define weechat_infolist_prev(__list) \
#define weechat_infolist_prev(__list) \
weechat_plugin->infolist_prev(__list)
#define weechat_infolist_fields(__list) \
#define weechat_infolist_reset_item_cursor(__list) \
weechat_plugin->infolist_reset_item_cursor(__list)
#define weechat_infolist_fields(__list) \
weechat_plugin->infolist_fields(__list)
#define weechat_infolist_integer(__item, __var) \
#define weechat_infolist_integer(__item, __var) \
weechat_plugin->infolist_integer(__item, __var)
#define weechat_infolist_string(__item, __var) \
#define weechat_infolist_string(__item, __var) \
weechat_plugin->infolist_string(__item, __var)
#define weechat_infolist_pointer(__item, __var) \
#define weechat_infolist_pointer(__item, __var) \
weechat_plugin->infolist_pointer(__item, __var)
#define weechat_infolist_time(__item, __var) \
#define weechat_infolist_buffer(__item, __var, __size) \
weechat_plugin->infolist_buffer(__item, __var, __size)
#define weechat_infolist_time(__item, __var) \
weechat_plugin->infolist_time(__item, __var)
#define weechat_infolist_free(__list) \
#define weechat_infolist_free(__list) \
weechat_plugin->infolist_free(__list)
/* upgrade */
#define weechat_upgrade_create(__filename, __write) \
weechat_plugin->upgrade_create(__filename, __write)
#define weechat_upgrade_write_object(__upgrade_file, __object_id, \
__infolist) \
weechat_plugin->upgrade_write_object(__upgrade_file, __object_id, \
__infolist)
#define weechat_upgrade_read(__upgrade_file, __callback) \
weechat_plugin->upgrade_read(__upgrade_file, __callback)
#define weechat_upgrade_close(__upgrade_file) \
weechat_plugin->upgrade_close(__upgrade_file)
#endif /* weechat-plugin.h */
+2 -1
View File
@@ -22,7 +22,8 @@ xfer-command.c xfer-command.h
xfer-config.c xfer-config.h
xfer-dcc.c xfer-dcc.h
xfer-file.c xfer-file.h
xfer-network.c xfer-network.h)
xfer-network.c xfer-network.h
xfer-upgrade.c xfer-upgrade.h)
SET_TARGET_PROPERTIES(xfer PROPERTIES PREFIX "")
TARGET_LINK_LIBRARIES(xfer)
+3 -1
View File
@@ -35,7 +35,9 @@ xfer_la_SOURCES = xfer.c \
xfer-file.c \
xfer-file.h \
xfer-network.c \
xfer-network.h
xfer-network.h \
xfer-upgrade.c \
xfer-upgrade.h
xfer_la_LDFLAGS = -module
xfer_la_LIBADD = $(XFER_LFLAGS)
+1 -1
View File
@@ -245,7 +245,7 @@ xfer_buffer_refresh (const char *hotlist)
}
line++;
}
weechat_buffer_set (xfer_buffer, "hotlist", hotlist);
weechat_buffer_set (xfer_buffer, "hotlist", (void *)hotlist);
}
}
+3
View File
@@ -24,6 +24,9 @@ extern struct t_gui_buffer *xfer_buffer;
extern int xfer_buffer_selected_line;
extern void xfer_buffer_refresh (const char *hotlist);
extern int xfer_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
const char *input_data);
extern int xfer_buffer_close_cb (void *data, struct t_gui_buffer *buffer);
extern void xfer_buffer_open ();
#endif /* xfer-buffer.h */
+122
View File
@@ -0,0 +1,122 @@
/*
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
/* xfer-upgrade.c: save/restore xfer plugin data */
#include <stdlib.h>
#include "../weechat-plugin.h"
#include "xfer.h"
#include "xfer-upgrade.h"
#include "xfer-buffer.h"
/*
* xfer_upgrade_save_xfers: save xfers info to upgrade file
*/
int
xfer_upgrade_save_xfers (struct t_upgrade_file *upgrade_file)
{
/* TODO: save xfer data */
(void) upgrade_file;
return 1;
}
/*
* xfer_upgrade_save: save upgrade file
* return 1 if ok, 0 if error
*/
int
xfer_upgrade_save ()
{
int rc;
struct t_upgrade_file *upgrade_file;
upgrade_file = weechat_upgrade_create (XFER_UPGRADE_FILENAME, 1);
if (!upgrade_file)
return 0;
rc = xfer_upgrade_save_xfers (upgrade_file);
weechat_upgrade_close (upgrade_file);
return rc;
}
/*
* xfer_upgrade_set_buffer_callbacks: restore buffers callbacks (input and
* close) for buffers created by xfer plugin
*/
void
xfer_upgrade_set_buffer_callbacks ()
{
struct t_infolist *infolist;
struct t_gui_buffer *ptr_buffer;
infolist = weechat_infolist_get ("buffer", NULL, NULL);
if (infolist)
{
while (weechat_infolist_next (infolist))
{
if (weechat_infolist_pointer (infolist, "plugin") == weechat_xfer_plugin)
{
ptr_buffer = weechat_infolist_pointer (infolist, "pointer");
weechat_buffer_set (ptr_buffer, "close_callback", &xfer_buffer_close_cb);
weechat_buffer_set (ptr_buffer, "input_callback", &xfer_buffer_input_cb);
}
}
}
}
/*
* xfer_upgrade_read_cb: read callback for xfer upgrade file
*/
int
xfer_upgrade_read_cb (int object_id,
struct t_infolist *infolist)
{
/* TODO: write xfer read cb */
(void) object_id;
(void) infolist;
return WEECHAT_RC_OK;
}
/*
* xfer_upgrade_load: load upgrade file
* return 1 if ok, 0 if error
*/
int
xfer_upgrade_load ()
{
int rc;
struct t_upgrade_file *upgrade_file;
xfer_upgrade_set_buffer_callbacks ();
upgrade_file = weechat_upgrade_create (XFER_UPGRADE_FILENAME, 0);
rc = weechat_upgrade_read (upgrade_file, &xfer_upgrade_read_cb);
return rc;
}
+35
View File
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WEECHAT_XFER_UPGRADE_H
#define __WEECHAT_XFER_UPGRADE_H 1
#define XFER_UPGRADE_FILENAME "xfer"
/* For developers: please add new values ONLY AT THE END of enums */
enum t_xfer_upgrade_type
{
XFER_UPGRADE_TYPE_XFER = 0,
};
extern int xfer_upgrade_save ();
extern int xfer_upgrade_load ();
#endif /* xfer-upgrade.h */
+48 -20
View File
@@ -37,6 +37,7 @@
#include "xfer-config.h"
#include "xfer-file.h"
#include "xfer-network.h"
#include "xfer-upgrade.h"
WEECHAT_PLUGIN_NAME("xfer");
@@ -70,6 +71,28 @@ int xfer_count = 0; /* number of xfer */
int xfer_debug = 0;
int xfer_signal_upgrade_received = 0; /* signal "upgrade" received ? */
/*
* xfer_signal_upgrade_cb: callback for "upgrade" signal
*/
int
xfer_signal_upgrade_cb (void *data, const char *signal, const char *type_data,
void *signal_data)
{
/* make C compiler happy */
(void) data;
(void) signal;
(void) type_data;
(void) signal_data;
xfer_signal_upgrade_received = 1;
return WEECHAT_RC_OK;
}
/*
* xfer_create_directories: create directories for xfer plugin
@@ -296,8 +319,8 @@ xfer_port_in_use (int port)
void
xfer_send_signal (struct t_xfer *xfer, const char *signal)
{
struct t_plugin_infolist *infolist;
struct t_plugin_infolist_item *item;
struct t_infolist *infolist;
struct t_infolist_item *item;
char str_long[128];
infolist = weechat_infolist_new ();
@@ -607,7 +630,7 @@ xfer_free (struct t_xfer *xfer)
int
xfer_add_cb (void *data, const char *signal, const char *type_data, void *signal_data)
{
struct t_plugin_infolist *infolist;
struct t_infolist *infolist;
char *plugin_name, *plugin_id, *str_type, *str_protocol;
char *remote_nick, *local_nick, *filename;
int type, protocol;
@@ -635,7 +658,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, void *signal
return WEECHAT_RC_ERROR;
}
infolist = (struct t_plugin_infolist *)signal_data;
infolist = (struct t_infolist *)signal_data;
if (!weechat_infolist_next (infolist))
{
@@ -959,7 +982,7 @@ int
xfer_start_resume_cb (void *data, const char *signal, const char *type_data,
void *signal_data)
{
struct t_plugin_infolist *infolist;
struct t_infolist *infolist;
struct t_xfer *ptr_xfer;
char *plugin_name, *plugin_id, *filename, *str_start_resume;
int port;
@@ -978,7 +1001,7 @@ xfer_start_resume_cb (void *data, const char *signal, const char *type_data,
return WEECHAT_RC_ERROR;
}
infolist = (struct t_plugin_infolist *)signal_data;
infolist = (struct t_infolist *)signal_data;
if (!weechat_infolist_next (infolist))
{
@@ -1036,7 +1059,7 @@ int
xfer_accept_resume_cb (void *data, const char *signal, const char *type_data,
void *signal_data)
{
struct t_plugin_infolist *infolist;
struct t_infolist *infolist;
struct t_xfer *ptr_xfer;
char *plugin_name, *plugin_id, *filename, *str_start_resume;
int port;
@@ -1055,7 +1078,7 @@ xfer_accept_resume_cb (void *data, const char *signal, const char *type_data,
return WEECHAT_RC_ERROR;
}
infolist = (struct t_plugin_infolist *)signal_data;
infolist = (struct t_infolist *)signal_data;
if (!weechat_infolist_next (infolist))
{
@@ -1237,25 +1260,30 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
/* make C compiler happy */
(void) plugin;
for (ptr_xfer = xfer_list; ptr_xfer; ptr_xfer = ptr_xfer->next_xfer)
xfer_config_write ();
if (xfer_signal_upgrade_received)
xfer_upgrade_save ();
else
{
if (ptr_xfer->sock >= 0)
for (ptr_xfer = xfer_list; ptr_xfer; ptr_xfer = ptr_xfer->next_xfer)
{
if (ptr_xfer->status == XFER_STATUS_ACTIVE)
if (ptr_xfer->sock >= 0)
{
weechat_printf (NULL,
_("%s%s: aborting active xfer: \"%s\" from %s"),
weechat_prefix ("error"), "xfer",
ptr_xfer->filename, ptr_xfer->remote_nick);
weechat_log_printf (_("%s%s: aborting active xfer: \"%s\" from %s"),
"", "xfer",
if (ptr_xfer->status == XFER_STATUS_ACTIVE)
{
weechat_printf (NULL,
_("%s%s: aborting active xfer: \"%s\" from %s"),
weechat_prefix ("error"), "xfer",
ptr_xfer->filename, ptr_xfer->remote_nick);
weechat_log_printf (_("%s%s: aborting active xfer: \"%s\" from %s"),
"", "xfer",
ptr_xfer->filename, ptr_xfer->remote_nick);
}
xfer_close (ptr_xfer, XFER_STATUS_FAILED);
}
xfer_close (ptr_xfer, XFER_STATUS_FAILED);
}
}
xfer_config_write ();
return WEECHAT_RC_OK;
}