Commit 1335223f authored by stettberger's avatar stettberger

* /update refreshes the buddylist by the pubkey's in $HOME/.silc/buddylist

parent 4398d058
......@@ -31,6 +31,7 @@ typedef struct BuddyStruct {
Buddy buddies=NULL;
int buddy_conns[MAX_CONNS];
int buddyfd=0;
SILC_TASK_CALLBACK(si_handle_buddyfd_input);
void send_buddy_list(int fd);
......@@ -127,30 +128,18 @@ void add_pubkey_callback(SilcClient client, SilcClientConnection conn,
}
}
void init_buddylist() {
DIR *dir;
char *pubkey, *path;
void update_buddylist() {
/* Update the buddylist itself by the Pubkey's in $HOME/.silc/buddylist*/
struct dirent *entry;
struct sockaddr_un strAddr;
socklen_t lenAddr;
int yes=1;
int i=0;
while(i<MAX_CONNS){
buddy_conns[i]=0;
i++;
}
/* Init the buddylist itself */
path=malloc(strlen(getenv("HOME"))+40);
char *path=malloc(strlen(getenv("HOME"))+40);
NULL_TEST(path);
sprintf(path, "%s/.silc/buddylist", (char *)getenv("HOME"));
create_dirtree(path);
dir=opendir(path);
DIR *dir=opendir(path);
while((entry=readdir(dir))) {
if(entry->d_name[0]=='.')
continue;
pubkey=malloc(strlen(path)+strlen(entry->d_name)+2);
char *pubkey=malloc(strlen(path)+strlen(entry->d_name)+2);
NULL_TEST(pubkey);
sprintf(pubkey, "%s/%s", path, entry->d_name);
add_pubkey(pubkey);
......@@ -158,8 +147,23 @@ void init_buddylist() {
}
closedir(dir);
free(path);
}
void init_buddylist() {
struct sockaddr_un strAddr;
socklen_t lenAddr;
int yes=1;
int i=0;
while(i<MAX_CONNS){
buddy_conns[i]=0;
i++;
}
update_buddylist();
/* Buddyfd */
path=malloc(strlen(ircdir)+20);
char *path=malloc(strlen(ircdir)+20);
NULL_TEST(path);
sprintf(path,"%s/buddylist", ircdir);
unlink(path);
......
......@@ -7,9 +7,10 @@ install:
cp irc_client ${HOME}/bin
cp connect ${HOME}/bin
cp demultiplexer.py ${HOME}/bin
cp buddylist ${HOME}/bin
@echo
@echo "Installed stiis"
@echo
@echo "*******************************************"
@echo "* See README for details in Configuration *"
@echo "*******************************************"
\ No newline at end of file
@echo "*******************************************"
......@@ -134,7 +134,7 @@ SilcClientOperations ops;
Silc silc_client;
time_t last_input;
int transfer_count=1;
int buddyfd=0;
void DEBUG(char *fmt, ...);
int LocalToUtf8 (char *from, char **to);
......@@ -247,6 +247,18 @@ void sig_handler(int sig){
else
silc_client_command_call(silc_client->client, silc_client->conn, "quit Leaving", NULL);
}
close(buddyfd);
int i;
for (i=0; i < MAX_CONNS; i++){
if(!buddy_conns[i])
continue;
close(buddy_conns[i]);
}
char *fd=malloc(strlen(ircdir)+15);
NULL_TEST(fd);
sprintf(fd, "%s/buddylist", ircdir);
unlink(fd);
free(fd);
}
/* }}} */
......@@ -306,6 +318,10 @@ void proc_channels_input(Channel *c, char *buf) {
buf=strchr(&buf[1], ' ')+1;
silc_client_command_call(silc_client->client, silc_client->conn, NULL, "NICK", buf, NULL);
}
else if (!strncmp("update", &buf[1],6)) {
update_buddylist();
refresh_buddylist();
}
else if (!strncmp("me ", &buf[1], 3) && strlen(&buf[1])>3){
DEBUG("Input: ACTION");
if (strlen(c->silc->channel_name)!=0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment