forked from PsychoticNinja/irssi
Fixes to allow -append and -prepend work when there's only one file being
sent to wanted nick + typo bugfix. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2997 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
087e5ee525
commit
be1cd41a34
@ -41,13 +41,12 @@ int dcc_queue_old(const char *nick, const char *servertag)
|
|||||||
for (i = 0; i < queuelist->len; i++) {
|
for (i = 0; i < queuelist->len; i++) {
|
||||||
GSList *qlist = g_ptr_array_index(queuelist, i);
|
GSList *qlist = g_ptr_array_index(queuelist, i);
|
||||||
|
|
||||||
if (qlist == NULL)
|
for (; qlist != NULL; qlist = qlist->next) {
|
||||||
continue;
|
|
||||||
|
|
||||||
/* skip stub */
|
|
||||||
for (qlist = qlist->next; qlist != NULL; qlist = qlist->next) {
|
|
||||||
DCC_QUEUE_REC *rec = qlist->data;
|
DCC_QUEUE_REC *rec = qlist->data;
|
||||||
|
|
||||||
|
if (rec == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (*nick != '\0' && g_strcasecmp(nick, rec->nick) != 0)
|
if (*nick != '\0' && g_strcasecmp(nick, rec->nick) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -81,6 +80,16 @@ int dcc_queue_new(void)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void dcc_queue_free_rec(DCC_QUEUE_REC *rec)
|
||||||
|
{
|
||||||
|
if (rec != NULL) {
|
||||||
|
g_free(rec->servertag);
|
||||||
|
g_free(rec->nick);
|
||||||
|
g_free(rec->file);
|
||||||
|
g_free(rec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void dcc_queue_free(int queue)
|
void dcc_queue_free(int queue)
|
||||||
{
|
{
|
||||||
GSList **qlist;
|
GSList **qlist;
|
||||||
@ -88,18 +97,12 @@ void dcc_queue_free(int queue)
|
|||||||
g_assert(queue >= 0 && queue < queuelist->len);
|
g_assert(queue >= 0 && queue < queuelist->len);
|
||||||
|
|
||||||
qlist = (GSList **) &g_ptr_array_index(queuelist, queue);
|
qlist = (GSList **) &g_ptr_array_index(queuelist, queue);
|
||||||
g_assert(*qlist != NULL && (*qlist)->next == NULL);
|
while (*qlist != NULL) {
|
||||||
|
DCC_QUEUE_REC *rec = (*qlist)->data;
|
||||||
|
|
||||||
g_slist_free(*qlist);
|
*qlist = (*qlist)->next;
|
||||||
*qlist = NULL;
|
dcc_queue_free_rec(rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dcc_queue_free_rec(DCC_QUEUE_REC *rec)
|
|
||||||
{
|
|
||||||
g_free(rec->servertag);
|
|
||||||
g_free(rec->nick);
|
|
||||||
g_free(rec->file);
|
|
||||||
g_free(rec);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add an element to queue. element will have nick/servertag/fname/chat as data.
|
/* add an element to queue. element will have nick/servertag/fname/chat as data.
|
||||||
@ -127,9 +130,10 @@ void dcc_queue_add(int queue, int mode, const char *nick, const char *fname,
|
|||||||
*qlist = g_slist_append(*qlist, rec);
|
*qlist = g_slist_append(*qlist, rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* removes the head or the tail from the queue, but not the stub. returns the
|
/* removes the head or the tail from the queue. returns the number of
|
||||||
number of elements removed from the queue (0 or 1). if remove_head is
|
elements removed from the queue (0 or 1). if remove_head is non-zero,
|
||||||
non-zero, the head is removed. otherwise the tail is removed */
|
the head is removed (or actually stub is removed and the current head
|
||||||
|
becomes the stub), otherwise the tail is removed. */
|
||||||
static int dcc_queue_remove_entry(int queue, int remove_head)
|
static int dcc_queue_remove_entry(int queue, int remove_head)
|
||||||
{
|
{
|
||||||
DCC_QUEUE_REC *rec;
|
DCC_QUEUE_REC *rec;
|
||||||
@ -141,7 +145,7 @@ static int dcc_queue_remove_entry(int queue, int remove_head)
|
|||||||
if (*qlist == NULL || (*qlist)->next == NULL)
|
if (*qlist == NULL || (*qlist)->next == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
rec = remove_head ? (*qlist)->next->data : g_slist_last(*qlist)->data;
|
rec = remove_head ? (*qlist)->data : g_slist_last(*qlist)->data;
|
||||||
*qlist = g_slist_remove(*qlist, rec);
|
*qlist = g_slist_remove(*qlist, rec);
|
||||||
|
|
||||||
dcc_queue_free_rec(rec);
|
dcc_queue_free_rec(rec);
|
||||||
@ -192,13 +196,10 @@ static void sig_dcc_destroyed(CHAT_DCC_REC *dcc)
|
|||||||
for (i = 0; i < queuelist->len; i++) {
|
for (i = 0; i < queuelist->len; i++) {
|
||||||
GSList *qlist = g_ptr_array_index(queuelist, i);
|
GSList *qlist = g_ptr_array_index(queuelist, i);
|
||||||
|
|
||||||
if (qlist == NULL)
|
for (; qlist != NULL; qlist = qlist->next) {
|
||||||
continue;
|
|
||||||
|
|
||||||
for (qlist = qlist->next; qlist != NULL; qlist = qlist->next) {
|
|
||||||
DCC_QUEUE_REC *rec = qlist->data;
|
DCC_QUEUE_REC *rec = qlist->data;
|
||||||
|
|
||||||
if (rec->chat == dcc)
|
if (rec != NULL && rec->chat == dcc)
|
||||||
rec->chat = NULL;
|
rec->chat = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,7 +217,7 @@ void dcc_queue_deinit(void)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < queuelist->len; i++)
|
for (i = 0; i < queuelist->len; i++)
|
||||||
while (dcc_queue_remove_head(i) != 0) ;
|
dcc_queue_free(i);
|
||||||
|
|
||||||
g_ptr_array_free(queuelist, TRUE);
|
g_ptr_array_free(queuelist, TRUE);
|
||||||
|
|
||||||
|
@ -18,11 +18,6 @@
|
|||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <glob.h>
|
|
||||||
|
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
@ -37,8 +32,10 @@
|
|||||||
#include "dcc-chat.h"
|
#include "dcc-chat.h"
|
||||||
#include "dcc-queue.h"
|
#include "dcc-queue.h"
|
||||||
|
|
||||||
|
#include <glob.h>
|
||||||
|
|
||||||
#ifndef GLOB_TILDE
|
#ifndef GLOB_TILDE
|
||||||
# define GLOBL_TILDE 0
|
# define GLOB_TILDE 0 /* unsupported */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int dcc_send_one_file(int queue, const char *target, const char *fname,
|
static int dcc_send_one_file(int queue, const char *target, const char *fname,
|
||||||
@ -161,13 +158,16 @@ static void cmd_dcc_send(const char *data, IRC_SERVER_REC *server,
|
|||||||
|
|
||||||
if (g_hash_table_lookup(optlist, "rmhead") != NULL) {
|
if (g_hash_table_lookup(optlist, "rmhead") != NULL) {
|
||||||
queue = dcc_queue_old(nick, servertag);
|
queue = dcc_queue_old(nick, servertag);
|
||||||
|
if (queue != -1)
|
||||||
dcc_queue_remove_head(queue);
|
dcc_queue_remove_head(queue);
|
||||||
} else if (g_hash_table_lookup(optlist, "rmtail") != NULL) {
|
} else if (g_hash_table_lookup(optlist, "rmtail") != NULL) {
|
||||||
queue = dcc_queue_old(nick, servertag);
|
queue = dcc_queue_old(nick, servertag);
|
||||||
|
if (queue != -1)
|
||||||
dcc_queue_remove_tail(queue);
|
dcc_queue_remove_tail(queue);
|
||||||
} else if (g_hash_table_lookup(optlist, "flush") != NULL) {
|
} else if (g_hash_table_lookup(optlist, "flush") != NULL) {
|
||||||
queue = dcc_queue_old(nick, servertag);
|
queue = dcc_queue_old(nick, servertag);
|
||||||
while (dcc_queue_remove_head(queue)) ;
|
if (queue != -1)
|
||||||
|
dcc_queue_free(queue);
|
||||||
} else {
|
} else {
|
||||||
if (g_hash_table_lookup(optlist, "append") != NULL)
|
if (g_hash_table_lookup(optlist, "append") != NULL)
|
||||||
mode = DCC_QUEUE_APPEND;
|
mode = DCC_QUEUE_APPEND;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user