void silc_plugin_connected(SilcClient client, SilcClientConnection conn, SilcClientConnectionStatus status, SilcStatus error, const char *message, void *context) { SilcConnectionContext connContext; SilcPluginServerList server; server = find_server_for_buffer(context); if (status == SILC_CLIENT_CONN_DISCONNECTED) { weechat_log_printf("Disconnected: %s", message ? message : ""); weechat_buffer_close(context); remove_server(server); return; } if (status != SILC_CLIENT_CONN_SUCCESS && status != SILC_CLIENT_CONN_SUCCESS_RESUME) { weechat_log_printf("Error connecting to server: %d", status); return; } connContext = malloc(sizeof(SilcConnectionContext)); connContext->server_buffer = context; conn->context = connContext; server->connection = conn; weechat_log_printf("connection successfull"); }
void stop_server() { stop_timer(); //stop_handlers(); destroy_sock_list(); close(server_sock); remove_server(g_server); }
void MainWindow::on_toolButton_2_clicked() { if (ui->comboBox->currentText().isEmpty() == false) { QMessageBox mbox; int ret; mbox.setText(QObject::tr("Are you sure you want to remove ") + ui->comboBox->currentText() + "?"); mbox.setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok); mbox.setDefaultButton(QMessageBox::Cancel); mbox.setButtonText(QMessageBox::Ok, tr("Remove")); ret = mbox.exec(); if (ret == QMessageBox::Ok) { remove_server(settings, ui->comboBox->currentText()); reload_settings(); } } }
void handle_message(void* received, int msg_type){ MSG_CHAT_MESSAGE msg = *(MSG_CHAT_MESSAGE*)(received); MSG_RESPONSE rsp; rsp.type = RESPONSE; if (msg.msg_type == PUBLIC) { if (is_local_user(msg.sender)) { // if sender send msg to its parent server int servers_to_removed[REPO_SIZE]; int servers_to_send[REPO_SIZE]; int i; for (i=0; i<REPO_SIZE; ++i) { servers_to_send[i] = 0; servers_to_removed[i] = 0; } lock_repo(); int j,k; int all_servers_exists = TRUE; for (i=0, j=0, k=0; i<REPO_SIZE; ++i) { if ( !strcmp(SHM_ROOM_SERVER_ADRESS[i].room_name, msg.receiver) && SHM_ROOM_SERVER_ADRESS[i].server_id != MSG_RECEIVER && SHM_ROOM_SERVER_ADRESS[i].server_id != -1 ) { if (!await_server_response(SHM_ROOM_SERVER_ADRESS[i].server_id)) { all_servers_exists = FALSE; servers_to_removed[j] = SHM_ROOM_SERVER_ADRESS[i].server_id; ++j; } else { servers_to_send[k] = SHM_ROOM_SERVER_ADRESS[i].server_id; ++k; } } } unlock_repo(); if (all_servers_exists) { for (i=0; i<REPO_SIZE; ++i) { if (servers_to_send[i]) { msgsnd(servers_to_send[i], &msg, _size(MSG_CHAT_MESSAGE), 0); } } } else { for (i=0; i<REPO_SIZE; ++i) { if(servers_to_removed[i]) { remove_server(servers_to_removed[i]); } } rsp.response_type = MSG_NOT_SEND; strcpy(rsp.content, "NOT EVERY SERVER RESPONDED"); } for (i=0; i<MAX_USERS_NUMBER; ++i) { if( !strcmp(LOCAL_REPO[i].room_name, msg.receiver) ) { msgsnd(LOCAL_REPO[i].client_id, &msg, _size(MSG_CHAT_MESSAGE), 0); } } } else { // if we are the second server and we send msg to users int i; for (i=0; i<MAX_USERS_NUMBER; ++i) { if( !strcmp(LOCAL_REPO[i].room_name, msg.receiver) ) { msgsnd(LOCAL_REPO[i].client_id, &msg, _size(MSG_CHAT_MESSAGE), 0); } } } } else if (msg.msg_type == PRIVATE) { int node_server_id = check_if_user_exists(msg.receiver); if(node_server_id == MSG_RECEIVER) { msgsnd(get_user_id(msg.receiver), &msg, _size(MSG_CHAT_MESSAGE), 0); } else if (node_server_id != FALSE) { if (await_server_response(node_server_id)) { msgsnd(node_server_id, &msg, _size(MSG_CHAT_MESSAGE), 0); } else { rsp.response_type = MSG_NOT_SEND; strcpy(rsp.content, "SERVER DID NOT RESPOND"); remove_server(node_server_id); } } else if (node_server_id == FALSE) { rsp.response_type = MSG_NOT_SEND; strcpy(rsp.content, "USER DOESNT EXIST!"); } } msgsnd(get_user_id(msg.sender), &rsp, _size(MSG_RESPONSE), 0); }