/* * Sets up the profile for alias and initializes wallDialog and friendDialog. */ void Facepamphlet::loginAlias(QString alias) { // Setup profile image QString profileImageSource = ":/images_section/"; if(alias.compare("Cheryl/Carol/Cristal") == 0) { profileImageSource += "cheryl"; } else if(alias.compare("Lana Kain") == 0) { profileImageSource += "lana"; } else { profileImageSource += alias.toLower(); } QPixmap image = QPixmap(profileImageSource); profileIcon->setPixmap(image.scaledToHeight(std::min(200, image.height()))); // Setup selfInfo selfInfo.image = QIcon(profileImageSource); selfInfo.alias = alias; // Setup visual layout settings for wallPostList wallPostList->setIconSize(QSize(50,50)); wallPostList->setSpacing(1); wallPostList->setWordWrap(true); // Setup visual layout settings for wallPostList friendsList->setIconSize(QSize(50,50)); // Initialize dialogs // Initialize the wallDialog (for posts to wall by friends) wallDialog = new WallDialog; // Initialize the friendsDialog (for adding friends) friendDialog = new FriendDialog(alias); // Setup connections connect(selfPostButton, SIGNAL(clicked()), this, SLOT(selfWallPost())); connect(friendRemoveButton, SIGNAL(clicked()), this, SLOT(friendRemove())); connect(friendAddButton, SIGNAL(clicked()), this, SLOT(showFriendDialog())); connect(friendWallButton, SIGNAL(clicked()), this, SLOT(showWallDialog())); // Connect with friendDialog connect(this, SIGNAL(setDefaults()), friendDialog, SLOT(addDefaultFriends())); connect(friendDialog, SIGNAL(addFriend(friendInfo)), this, SLOT(friendAdded(friendInfo))); connect(this, SIGNAL(friendRemoved(friendInfo)), friendDialog, SLOT(friendRemoved(friendInfo))); // Connect with wallDialog connect(this, SIGNAL(friendRemoved(friendInfo)), wallDialog, SLOT(friendRemoved(friendInfo))); connect(friendDialog, SIGNAL(addFriend(friendInfo)), wallDialog, SLOT(friendAdded(friendInfo))); // Emit signal to cause friendDialog to add a few default friends emit setDefaults(); // Show main window show(); }
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui_(new Ui::MainWindow), data_file_name_(DATA_FILE_PATH), password_(QString()), money_(Money()) { ui_->setupUi(this); connect(ui_->ActionChangePass, SIGNAL(triggered()), this, SLOT(changePassword())); connect(ui_->ActionSave, SIGNAL(triggered()), this, SLOT(saveData())); connect(ui_->ActionExit, SIGNAL(triggered()), this, SLOT(requestExit())); connect(ui_->ActionUpdate, SIGNAL(triggered()), this, SLOT(updateState())); connect(ui_->AddEventButton, SIGNAL(clicked()), this, SLOT(addEvent())); connect(ui_->AddFriendButton, SIGNAL(clicked()), this, SLOT(addFriend())); connect(ui_->DelEventsButton, SIGNAL(clicked()), this, SLOT(delEvents())); connect(ui_->DelFriendsButton, SIGNAL(clicked()), this, SLOT(delFriends())); // financial events connect(ui_->CurRubNalEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); connect(ui_->CurEurNalEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); connect(ui_->CurUsdNalEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); connect(ui_->CurRubElecEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); connect(ui_->CurEurElecEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); connect(ui_->CurUsdElecEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); connect(ui_->OldRubNalEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); connect(ui_->OldEurNalEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); connect(ui_->OldUsdNalEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); connect(ui_->OldRubElecEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); connect(ui_->OldEurElecEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); connect(ui_->OldUsdElecEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); loadData(); updateState(); }
void FriendsWidget::onAddFriendButtonClicked() { AddFriendDialog dialog(this); if (dialog.exec() == QDialog::Accepted) { addFriend(dialog.getUserId(), dialog.getUsername()); emit friendRequested(dialog.getUserId(), dialog.getMessage()); } }
void BuddyModel::setFilterByName(const QString &filter) { m_filterByName = filter; emit filterByNameChanged(filter); //TODO write more fast algorythm clear(); foreach (auto buddy, m_roster.data()->findChildren<Vreen::Buddy*>()) addFriend(buddy); }
void SearchDlg::addContactClick() { if (type_ == AddContact) { if (addJid_.isEmpty()) return; addFriend(); } else if (type_ == UserSearch) { QDialog::accept(); } }
//查找好友 FindFriend::FindFriend(QWidget *parent) : QDialog(parent), ui(new Ui::FindFriend) { ui->setupUi(this); Qt::WindowFlags flags=Qt::Dialog; flags |=Qt::WindowMinimizeButtonHint ; setWindowFlags(flags); this->setWindowTitle(LOCAL("添加好友")); connect(ui->pushButton,SIGNAL(clicked()),this,SLOT(addFriend())); }
void Monster::onCreatureFound(Creature* creature, bool pushFront/* = false*/) { if (isFriend(creature)) { addFriend(creature); } if (isOpponent(creature)) { addTarget(creature, pushFront); } updateIdleStatus(); }
void BuddyModel::setRoster(Vreen::Roster *roster) { if (!m_roster.isNull()) m_roster.data()->disconnect(this); m_roster = roster; foreach (auto buddy, m_roster.data()->buddies()) addFriend(buddy); connect(roster, SIGNAL(buddyAdded(Vreen::Buddy*)), SLOT(addFriend(Vreen::Buddy*))); connect(roster, SIGNAL(buddyRemoved(int)), SLOT(removeFriend(int))); emit rosterChanged(roster); }
BOOL LLPanelFriends::refreshNamesSync(const LLAvatarTracker::buddy_map_t & all_buddies) { mFriendsList->deleteAllItems(); BOOL have_names = TRUE; LLAvatarTracker::buddy_map_t::const_iterator buddy_it = all_buddies.begin(); for(; buddy_it != all_buddies.end(); ++buddy_it) { have_names &= addFriend(buddy_it->first); } return have_names; }
//READ---------------------------------------------------------------------------------- void MainThread::Read() { qCritical()<<"READ "; QTcpSocket* sock= ((QTcpSocket*)(this->sender())); QByteArray array=sock->readAll(); QString buffer = array; int id; id=cl->ID(sock); qCritical()<<buffer; if (!buffer.contains("#/")) { sock->disconnectFromHost(); return; } QStringList strList=buffer.split("#/"); if (strList.isEmpty()) return; QStringListIterator iter(strList); while(iter.hasNext()) { QString buf=iter.next(); if( buf.contains(structure.prefix+ structure.key+ structure.separator+structure.login+ structure.prefix) ) { qCritical()<<"RES2"; QSharedPointer<IMessage> mes(new Message(buf)); mes->AddPart(keys.s,QString::number(cl->ID(sock))); emit authentification(mes); return; } if( buf.contains(structure.prefix+structure.key+structure.separator+structure.send+structure.prefix)) { QSharedPointer<IMessage> mes(new Message(buf)); mes->AddPart(keys.s,QString::number(cl->ID(sock))); emit send(mes); return; } if( buf.contains(structure.prefix+structure.key+structure.separator+structure.addfriend+structure.prefix)) { addFriend(sock, id, buf); return; } if( buf.contains(structure.prefix+structure.key+structure.separator+structure.removefriend+structure.prefix)) { removeFriend(sock, id, buf); return; } } }
/** Constructor */ SecurityItem::SecurityItem(FeedHolder *parent, uint32_t feedId, std::string gpgId, std::string sslId, uint32_t type, bool isHome) :QWidget(NULL), mParent(parent), mFeedId(feedId), mSslId(sslId), mGpgId(gpgId), mType(type), mIsHome(isHome) { /* Invoke the Qt Designer generated object setup routine */ setupUi(this); messageframe->setVisible(false); sendmsgButton->setEnabled(false); quickmsgButton->setEnabled(false); chatButton->setEnabled(false); addFriendButton->setEnabled(false); removeFriendButton->setEnabled(false); removeFriendButton->hide(); peerDetailsButton->setEnabled(false); /* general ones */ connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) ); connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) ); /* specific ones */ connect( chatButton, SIGNAL( clicked( void ) ), this, SLOT( openChat ( void ) ) ); connect( actionNew_Message, SIGNAL( triggered( ) ), this, SLOT( sendMsg ( void ) ) ); connect( quickmsgButton, SIGNAL( clicked( ) ), this, SLOT( togglequickmessage() ) ); connect( cancelButton, SIGNAL( clicked( ) ), this, SLOT( togglequickmessage() ) ); connect( sendmsgButton, SIGNAL( clicked( ) ), this, SLOT( sendMessage() ) ); connect(addFriendButton, SIGNAL(clicked()), this, SLOT(addFriend())); connect(removeFriendButton, SIGNAL(clicked()), this, SLOT(removeFriend())); connect(peerDetailsButton, SIGNAL(clicked()), this, SLOT(peerDetails())); connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(updateItem())); QMenu *msgmenu = new QMenu(); msgmenu->addAction(actionNew_Message); quickmsgButton->setMenu(msgmenu); avatar->setId(mSslId, false); small(); updateItemStatic(); updateItem(); }
int friendFinder(){ // Receive Buffer int rxpos = 0; uint8_t rx[1024]; // Chat Packet SceNetAdhocctlChatPacketC2S chat; chat.base.opcode = OPCODE_CHAT; // Last Ping Time uint64_t lastping = 0; // Last Time Reception got updated uint64_t lastreceptionupdate = 0; uint64_t now; // Finder Loop while(friendFinderRunning) { // Acquire Network Lock //_acquireNetworkLock(); // Ping Server now = real_time_now()*1000.0; if(now - lastping >= 100) { // Update Ping Time lastping = now; // Prepare Packet uint8_t opcode = OPCODE_PING; // Send Ping to Server send(metasocket, (const char *)&opcode, 1,0); } // Send Chat Messages //while(popFromOutbox(chat.message)) //{ // // Send Chat to Server // sceNetInetSend(metasocket, (const char *)&chat, sizeof(chat), 0); //} // Wait for Incoming Data int received = recv(metasocket, (char *)(rx + rxpos), sizeof(rx) - rxpos,0); // Free Network Lock //_freeNetworkLock(); // Received Data if(received > 0) { // Fix Position rxpos += received; // Log Incoming Traffic //printf("Received %d Bytes of Data from Server\n", received); INFO_LOG(SCENET, "Received %d Bytes of Data from Adhoc Server", received); } // Handle Packets if(rxpos > 0) { // BSSID Packet if(rx[0] == OPCODE_CONNECT_BSSID) { // Enough Data available if(rxpos >= (int)sizeof(SceNetAdhocctlConnectBSSIDPacketS2C)) { // Cast Packet SceNetAdhocctlConnectBSSIDPacketS2C * packet = (SceNetAdhocctlConnectBSSIDPacketS2C *)rx; // Update BSSID parameter.bssid.mac_addr = packet->mac; // Change State threadStatus = ADHOCCTL_STATE_CONNECTED; // Notify Event Handlers CoreTiming::ScheduleEvent_Threadsafe_Immediate(eventHandlerUpdate, join32(ADHOCCTL_EVENT_CONNECT, 0)); // Move RX Buffer memmove(rx, rx + sizeof(SceNetAdhocctlConnectBSSIDPacketS2C), sizeof(rx) - sizeof(SceNetAdhocctlConnectBSSIDPacketS2C)); // Fix RX Buffer Length rxpos -= sizeof(SceNetAdhocctlConnectBSSIDPacketS2C); } } // Chat Packet else if(rx[0] == OPCODE_CHAT) { // Enough Data available if(rxpos >= (int)sizeof(SceNetAdhocctlChatPacketS2C)) { // Cast Packet SceNetAdhocctlChatPacketS2C * packet = (SceNetAdhocctlChatPacketS2C *)rx; // Fix for Idiots that try to troll the "ME" Nametag if(strcasecmp((char *)packet->name.data, "ME") == 0) strcpy((char *)packet->name.data, "NOT ME"); // Add Incoming Chat to HUD //printf("Receive chat message %s", packet->base.message); // Move RX Buffer memmove(rx, rx + sizeof(SceNetAdhocctlChatPacketS2C), sizeof(rx) - sizeof(SceNetAdhocctlChatPacketS2C)); // Fix RX Buffer Length rxpos -= sizeof(SceNetAdhocctlChatPacketS2C); } } // Connect Packet else if(rx[0] == OPCODE_CONNECT) { // Enough Data available if(rxpos >= (int)sizeof(SceNetAdhocctlConnectPacketS2C)) { // Log Incoming Peer INFO_LOG(SCENET,"Incoming Peer Data..."); // Cast Packet SceNetAdhocctlConnectPacketS2C * packet = (SceNetAdhocctlConnectPacketS2C *)rx; // Add User addFriend(packet); // Update HUD User Count #ifdef LOCALHOST_AS_PEER setUserCount(getActivePeerCount()); #else // setUserCount(getActivePeerCount()+1); #endif // Move RX Buffer memmove(rx, rx + sizeof(SceNetAdhocctlConnectPacketS2C), sizeof(rx) - sizeof(SceNetAdhocctlConnectPacketS2C)); // Fix RX Buffer Length rxpos -= sizeof(SceNetAdhocctlConnectPacketS2C); } } // Disconnect Packet else if(rx[0] == OPCODE_DISCONNECT) { // Enough Data available if(rxpos >= (int)sizeof(SceNetAdhocctlDisconnectPacketS2C)) { // Log Incoming Peer Delete Request INFO_LOG(SCENET,"FriendFinder: Incoming Peer Data Delete Request..."); // Cast Packet SceNetAdhocctlDisconnectPacketS2C * packet = (SceNetAdhocctlDisconnectPacketS2C *)rx; // Delete User by IP deleteFriendByIP(packet->ip); // Update HUD User Count #ifdef LOCALHOST_AS_PEER setUserCount(_getActivePeerCount()); #else //setUserCount(_getActivePeerCount()+1); #endif // Move RX Buffer memmove(rx, rx + sizeof(SceNetAdhocctlDisconnectPacketS2C), sizeof(rx) - sizeof(SceNetAdhocctlDisconnectPacketS2C)); // Fix RX Buffer Length rxpos -= sizeof(SceNetAdhocctlDisconnectPacketS2C); } } // Scan Packet else if(rx[0] == OPCODE_SCAN) { // Enough Data available if(rxpos >= (int)sizeof(SceNetAdhocctlScanPacketS2C)) { // Log Incoming Network Information INFO_LOG(SCENET,"Incoming Group Information..."); // Cast Packet SceNetAdhocctlScanPacketS2C * packet = (SceNetAdhocctlScanPacketS2C *)rx; // Allocate Structure Data SceNetAdhocctlScanInfo * group = (SceNetAdhocctlScanInfo *)malloc(sizeof(SceNetAdhocctlScanInfo)); // Allocated Structure Data if(group != NULL) { // Clear Memory memset(group, 0, sizeof(SceNetAdhocctlScanInfo)); // Link to existing Groups group->next = networks; // Copy Group Name group->group_name = packet->group; // Set Group Host group->bssid.mac_addr = packet->mac; // Link into Group List networks = group; } // Move RX Buffer memmove(rx, rx + sizeof(SceNetAdhocctlScanPacketS2C), sizeof(rx) - sizeof(SceNetAdhocctlScanPacketS2C)); // Fix RX Buffer Length rxpos -= sizeof(SceNetAdhocctlScanPacketS2C); } } // Scan Complete Packet else if(rx[0] == OPCODE_SCAN_COMPLETE) { // Log Scan Completion INFO_LOG(SCENET,"FriendFinder: Incoming Scan complete response..."); // Change State threadStatus = ADHOCCTL_STATE_DISCONNECTED; // Notify Event Handlers CoreTiming::ScheduleEvent_Threadsafe_Immediate(eventHandlerUpdate,join32(ADHOCCTL_EVENT_SCAN, 0)); //int i = 0; for(; i < ADHOCCTL_MAX_HANDLER; i++) //{ // // Active Handler // if(_event_handler[i] != NULL) _event_handler[i](ADHOCCTL_EVENT_SCAN, 0, _event_args[i]); //} // Move RX Buffer memmove(rx, rx + 1, sizeof(rx) - 1); // Fix RX Buffer Length rxpos -= 1; } } // Original value was 10 ms, I think 100 is just fine sleep_ms(100); } // Log Shutdown INFO_LOG(SCENET, "FriendFinder: End of Friend Finder Thread"); // Return Success return 0; }
int serverInit(LUser* luser){ DIR *dir,*user_dir,*dir_user; FILE *user_pass_file; struct dirent *dit,*dit_user; char *aux_path,*pass, *name; aux_path = (char*)malloc(256*sizeof(char)); //char path[100]; int num_user = 0,num_friends = 0; User *user; luser->numUser = 0; // Abrir el directorio server_data if ((dir = opendir(DATA_PATH)) == NULL){ sprintf(aux_path,"mkdir %s",DATA_PATH); system(aux_path); //perror("opendir"); return 0; } if(DEBUG_MODE) printf("serverInit -> Directorio: %s\n",DATA_PATH); // Recorrer el directorio server_data while ((dit = readdir(dir)) != NULL){ if(strcmp(dit->d_name,".") != 0 && strcmp(dit->d_name,"..") != 0){ //LEER CLAVE num_user++; // Directorio del pass del usuario = aux_path sprintf(aux_path,"%s%s/.pass",DATA_PATH,dit->d_name); if((user_pass_file = fopen(aux_path, "r")) == NULL){ perror("Error abriendo fichero"); return 0; } pass = (char*)malloc(256*sizeof(char)); fscanf( user_pass_file, "%s\\n", pass); addUsers(luser,dit->d_name,pass); if(DEBUG_MODE){ printf("serverInit -> Se ha añadido: %s %s\n",dit->d_name,pass); } if(fclose(user_pass_file) == -1){ perror("Error cerrando fichero"); } // LEER peticiones enviadas // Directorio de la lista de enviados = aux_path sprintf(aux_path,"%s%s/.send",DATA_PATH,dit->d_name); if((user_pass_file = fopen(aux_path, "r")) == NULL) perror("Error abriendo fichero"); name = (char*)malloc(256*sizeof(char)); while(!feof(user_pass_file)) { if(fgets(name,100,user_pass_file) != NULL) { //fscanf(user_pass_file,"%s\\n",name); name[strlen(name)-1] = '\0'; if(DEBUG_MODE) printf("serverInit -> Send: %s\n",name); user = luser->listU[num_user-1];// Coger el usuario actual addFriendRequestSend(user,name); } } if(fclose(user_pass_file) == -1) perror("Error abriendo fichero"); // LEER peticiones recibidas // Directorio de la lista de enviados = aux_path sprintf(aux_path,"%s%s/.pending",DATA_PATH,dit->d_name); if((user_pass_file = fopen(aux_path, "r")) == NULL) perror("Error abriendo fichero"); while(!feof(user_pass_file)) { if(fgets(name,100,user_pass_file) != NULL) { //fscanf(user_pass_file,"%s\\n",name); name[strlen(name)-1] = '\0'; if(DEBUG_MODE) printf("serverInit -> Pending: %s\n",name); user = luser->listU[num_user-1];// Coger el usuario actual addFriendRequestPending(user,name); } } if(fclose(user_pass_file) == -1) perror("Error abriendo fichero"); //LEER AMIGOS // Directorio del usuario = aux_path sprintf(aux_path,"%s%s/",DATA_PATH,dit->d_name); if ((dir_user = opendir(aux_path)) == NULL){ perror("opendir"); return 0; } //num_friends = 0; user = luser->listU[num_user-1];// Coger el usuario actual // Recorrer el directorio del usuario para añadir los amigos while ((dit_user = readdir(dir_user)) != NULL){ if(strcmp(dit_user->d_name,".") != 0 && strcmp(dit_user->d_name,"..") != 0 && strcmp(dit_user->d_name,".pass") != 0 && strcmp(dit_user->d_name,".pending") != 0 && strcmp(dit_user->d_name,".send") != 0){ addFriend(user,dit_user->d_name); if(DEBUG_MODE){ printf("serverInit -> %s añade a %s\n",user->nick,dit_user->d_name); } //num_friends++; } } if (closedir(dir_user) == -1){ perror("closedir"); return 0; } free(pass); free(name); //user->numFriends = num_friends; /*printf("\n%s", dit->d_name); printf(" %d", dit->d_reclen);*/ } } free(aux_path); /* int closedir(DIR *dir); * * Close the stream to argv[1]. And check for errors. */ if (closedir(dir) == -1){ perror("closedir"); return 0; } luser->numUser = num_user; if(DEBUG_MODE) printf("serverInit -> Exit Directorio: %s Users: %d\n",DATA_PATH,luser->numUser); return 0; }
int friendFinder(){ // Receive Buffer int rxpos = 0; uint8_t rx[1024]; // Chat Packet SceNetAdhocctlChatPacketC2S chat; chat.base.opcode = OPCODE_CHAT; // Last Ping Time uint64_t lastping = 0; // Last Time Reception got updated uint64_t lastreceptionupdate = 0; uint64_t now; // Log Startup INFO_LOG(SCENET, "FriendFinder: Begin of Friend Finder Thread"); // Finder Loop while(friendFinderRunning) { // Acquire Network Lock //_acquireNetworkLock(); // Ping Server now = real_time_now()*1000.0; if(now - lastping >= 100) { // Update Ping Time lastping = now; // Prepare Packet uint8_t opcode = OPCODE_PING; // Send Ping to Server, may failed with socket error 10054/10053 if someone else with the same IP already connected to AdHoc Server (the server might need to be modified to differentiate MAC instead of IP) int iResult = send(metasocket, (const char *)&opcode, 1,0); /*if (iResult == SOCKET_ERROR) { ERROR_LOG(SCENET, "FriendFinder: Socket Error (%i) when sending OPCODE_PING", errno); //friendFinderRunning = false; }*/ } // Send Chat Messages //while(popFromOutbox(chat.message)) //{ // // Send Chat to Server // sceNetInetSend(metasocket, (const char *)&chat, sizeof(chat), 0); //} // Wait for Incoming Data int received = recv(metasocket, (char *)(rx + rxpos), sizeof(rx) - rxpos,0); // Free Network Lock //_freeNetworkLock(); // Received Data if(received > 0) { // Fix Position rxpos += received; // Log Incoming Traffic //printf("Received %d Bytes of Data from Server\n", received); INFO_LOG(SCENET, "Received %d Bytes of Data from Adhoc Server", received); } // Handle Packets if(rxpos > 0) { // BSSID Packet if(rx[0] == OPCODE_CONNECT_BSSID) { INFO_LOG(SCENET, "FriendFinder: Incoming OPCODE_CONNECT_BSSID"); // Enough Data available if(rxpos >= (int)sizeof(SceNetAdhocctlConnectBSSIDPacketS2C)) { // Cast Packet SceNetAdhocctlConnectBSSIDPacketS2C * packet = (SceNetAdhocctlConnectBSSIDPacketS2C *)rx; // Update BSSID parameter.bssid.mac_addr = packet->mac; // Change State threadStatus = ADHOCCTL_STATE_CONNECTED; // Notify Event Handlers CoreTiming::ScheduleEvent_Threadsafe_Immediate(eventHandlerUpdate, join32(ADHOCCTL_EVENT_CONNECT, 0)); // Move RX Buffer memmove(rx, rx + sizeof(SceNetAdhocctlConnectBSSIDPacketS2C), sizeof(rx) - sizeof(SceNetAdhocctlConnectBSSIDPacketS2C)); // Fix RX Buffer Length rxpos -= sizeof(SceNetAdhocctlConnectBSSIDPacketS2C); } } // Chat Packet else if(rx[0] == OPCODE_CHAT) { INFO_LOG(SCENET, "FriendFinder: Incoming OPCODE_CHAT"); // Enough Data available if(rxpos >= (int)sizeof(SceNetAdhocctlChatPacketS2C)) { // Cast Packet SceNetAdhocctlChatPacketS2C * packet = (SceNetAdhocctlChatPacketS2C *)rx; // Fix for Idiots that try to troll the "ME" Nametag if(strcasecmp((char *)packet->name.data, "ME") == 0) strcpy((char *)packet->name.data, "NOT ME"); // Add Incoming Chat to HUD //printf("Receive chat message %s", packet->base.message); DEBUG_LOG(SCENET, "Received chat message %s", packet->base.message); // Move RX Buffer memmove(rx, rx + sizeof(SceNetAdhocctlChatPacketS2C), sizeof(rx) - sizeof(SceNetAdhocctlChatPacketS2C)); // Fix RX Buffer Length rxpos -= sizeof(SceNetAdhocctlChatPacketS2C); } } // Connect Packet else if(rx[0] == OPCODE_CONNECT) { DEBUG_LOG(SCENET, "FriendFinder: OPCODE_CONNECT"); // Enough Data available if(rxpos >= (int)sizeof(SceNetAdhocctlConnectPacketS2C)) { // Log Incoming Peer INFO_LOG(SCENET,"Incoming Peer Data..."); // Cast Packet SceNetAdhocctlConnectPacketS2C * packet = (SceNetAdhocctlConnectPacketS2C *)rx; // Add User addFriend(packet); // Update HUD User Count #ifdef LOCALHOST_AS_PEER setUserCount(getActivePeerCount()); #else // setUserCount(getActivePeerCount()+1); #endif // Move RX Buffer memmove(rx, rx + sizeof(SceNetAdhocctlConnectPacketS2C), sizeof(rx) - sizeof(SceNetAdhocctlConnectPacketS2C)); // Fix RX Buffer Length rxpos -= sizeof(SceNetAdhocctlConnectPacketS2C); } } // Disconnect Packet else if(rx[0] == OPCODE_DISCONNECT) { DEBUG_LOG(SCENET, "FriendFinder: OPCODE_DISCONNECT"); // Enough Data available if(rxpos >= (int)sizeof(SceNetAdhocctlDisconnectPacketS2C)) { // Log Incoming Peer Delete Request INFO_LOG(SCENET,"FriendFinder: Incoming Peer Data Delete Request..."); // Cast Packet SceNetAdhocctlDisconnectPacketS2C * packet = (SceNetAdhocctlDisconnectPacketS2C *)rx; // Delete User by IP, should delete by MAC since IP can be shared (behind NAT) isn't? deleteFriendByIP(packet->ip); // Update HUD User Count #ifdef LOCALHOST_AS_PEER setUserCount(_getActivePeerCount()); #else //setUserCount(_getActivePeerCount()+1); #endif // Move RX Buffer memmove(rx, rx + sizeof(SceNetAdhocctlDisconnectPacketS2C), sizeof(rx) - sizeof(SceNetAdhocctlDisconnectPacketS2C)); // Fix RX Buffer Length rxpos -= sizeof(SceNetAdhocctlDisconnectPacketS2C); } } // Scan Packet else if(rx[0] == OPCODE_SCAN) { DEBUG_LOG(SCENET, "FriendFinder: OPCODE_SCAN"); // Enough Data available if(rxpos >= (int)sizeof(SceNetAdhocctlScanPacketS2C)) { // Log Incoming Network Information INFO_LOG(SCENET,"Incoming Group Information..."); // Cast Packet SceNetAdhocctlScanPacketS2C * packet = (SceNetAdhocctlScanPacketS2C *)rx; // Multithreading Lock peerlock.lock(); // It seems AdHoc Server always sent the full group list, so we should reset group list during Scan initialization // Should only add non-existing group (or replace an existing group) to prevent Ford Street Racing from showing a strange game session list /*SceNetAdhocctlScanInfo * group = findGroup(&packet->mac); if (group != NULL) { // Copy Group Name group->group_name = packet->group; // Set Group Host group->bssid.mac_addr = packet->mac; } else*/ { // Allocate Structure Data SceNetAdhocctlScanInfo * group = (SceNetAdhocctlScanInfo *)malloc(sizeof(SceNetAdhocctlScanInfo)); // Allocated Structure Data if (group != NULL) { // Clear Memory, should this be done only when allocating new group? memset(group, 0, sizeof(SceNetAdhocctlScanInfo)); // Link to existing Groups group->next = networks; // Copy Group Name group->group_name = packet->group; // Set Group Host group->bssid.mac_addr = packet->mac; // Link into Group List networks = group; } } // Multithreading Unlock peerlock.unlock(); // Move RX Buffer memmove(rx, rx + sizeof(SceNetAdhocctlScanPacketS2C), sizeof(rx) - sizeof(SceNetAdhocctlScanPacketS2C)); // Fix RX Buffer Length rxpos -= sizeof(SceNetAdhocctlScanPacketS2C); } } // Scan Complete Packet else if(rx[0] == OPCODE_SCAN_COMPLETE) { DEBUG_LOG(SCENET, "FriendFinder: OPCODE_SCAN_COMPLETE"); // Log Scan Completion INFO_LOG(SCENET,"FriendFinder: Incoming Scan complete response..."); // Change State threadStatus = ADHOCCTL_STATE_DISCONNECTED; // Notify Event Handlers CoreTiming::ScheduleEvent_Threadsafe_Immediate(eventHandlerUpdate,join32(ADHOCCTL_EVENT_SCAN, 0)); //int i = 0; for(; i < ADHOCCTL_MAX_HANDLER; i++) //{ // // Active Handler // if(_event_handler[i] != NULL) _event_handler[i](ADHOCCTL_EVENT_SCAN, 0, _event_args[i]); //} // Move RX Buffer memmove(rx, rx + 1, sizeof(rx) - 1); // Fix RX Buffer Length rxpos -= 1; } } // Original value was 10 ms, I think 100 is just fine sleep_ms(100); } // Groups/Networks should be deallocated isn't? // Prevent the games from having trouble to reInitiate Adhoc (the next NetInit -> PdpCreate after NetTerm) threadStatus = ADHOCCTL_STATE_DISCONNECTED; // Log Shutdown INFO_LOG(SCENET, "FriendFinder: End of Friend Finder Thread"); // Return Success return 0; }
/** Constructor */ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WindowFlags flags) : RWindow("MessengerWindow", parent, flags) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); setAttribute ( Qt::WA_DeleteOnClose, true ); ui.avatar->setFrameType(AvatarWidget::STATUS_FRAME); ui.avatar->setOwnId(); connect(ui.messagelineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(savestatusmessage())); connect(NotifyQt::getInstance(), SIGNAL(ownAvatarChanged()), this, SLOT(updateAvatar())); connect(NotifyQt::getInstance(), SIGNAL(ownStatusMessageChanged()), this, SLOT(loadmystatusmessage())); connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateOwnStatus(QString,int))); if (expandedPeers != NULL) { for (std::set<std::string>::iterator peerIt = expandedPeers->begin(); peerIt != expandedPeers->end(); peerIt++) { ui.friendList->addPeerToExpand(*peerIt); } delete expandedPeers; expandedPeers = NULL; } if (expandedGroups != NULL) { for (std::set<std::string>::iterator groupIt = expandedGroups->begin(); groupIt != expandedGroups->end(); groupIt++) { ui.friendList->addGroupToExpand(*groupIt); } delete expandedGroups; expandedGroups = NULL; } ui.messagelineEdit->setMinimumWidth(20); /* Initialize friend list */ QToolButton *button = new QToolButton(this); button->setIcon(QIcon(":/images/user/add_user24.png")); button->setToolTip(tr("Add a Friend")); connect(button, SIGNAL(clicked()), this, SLOT(addFriend())); ui.friendList->addToolButton(button); button = new QToolButton(this); button->setIcon(QIcon(":/images/friendsfolder24.png")); button->setToolTip(tr("Share files for your friends")); connect(button, SIGNAL(clicked()), this, SLOT(openShareManager())); ui.friendList->addToolButton(button); // load settings RsAutoUpdatePage::lockAllEvents(); ui.friendList->setShowStatusColumn(false); ui.friendList->setShowLastContactColumn(false); ui.friendList->setShowAvatarColumn(true); ui.friendList->setShowIPColumn(false); ui.friendList->setRootIsDecorated(true); ui.friendList->setShowGroups(false); processSettings(true); ui.friendList->setBigName(true); RsAutoUpdatePage::unlockAllEvents(); // add self nick RsPeerDetails pd; std::string ownId = rsPeers->getOwnId(); if (rsPeers->getPeerDetails(ownId, pd)) { /* calculate only once */ m_nickName = QString::fromUtf8(pd.name.c_str()); } /* Show nick and current state */ StatusInfo statusInfo; rsStatus->getOwnStatus(statusInfo); updateOwnStatus(QString::fromStdString(ownId), statusInfo.status); MainWindow *pMainWindow = MainWindow::getInstance(); if (pMainWindow) { QMenu *pStatusMenu = new QMenu(); pMainWindow->initializeStatusObject(pStatusMenu, true); ui.statusButton->setMenu(pStatusMenu); } loadmystatusmessage(); /* Hide platform specific features */ #ifdef Q_WS_WIN #endif }
/** Constructor */ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags) : RWindow("MainWindow", parent, flags) { /* Invoke the Qt Designer generated QObject setup routine */ ui.setupUi(this); /* Create RshareSettings object */ _settings = new RshareSettings(); setWindowTitle(tr("RetroShare %1 a secure decentralised commmunication platform").arg(retroshareVersion())); mSMPlayer = NULL; // Setting icons this->setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); /* Create all the dialogs of which we only want one instance */ _bandwidthGraph = new BandwidthGraph(); messengerWindow = new MessengerWindow(); _preferencesWindow = new PreferencesWindow(); applicationWindow = new ApplicationWindow(); applicationWindow->hide(); /** Left Side ToolBar**/ connect(ui.actionAdd_Friend, SIGNAL(triggered() ), this , SLOT( addFriend() ) ); connect(ui.actionAdd_Share, SIGNAL(triggered() ), this , SLOT( openShareManager() ) ); connect(ui.actionOptions, SIGNAL(triggered()), this, SLOT( showPreferencesWindow()) ); connect(ui.actionMessenger, SIGNAL(triggered()), this, SLOT( showMessengerWindow()) ); connect(ui.actionSMPlayer, SIGNAL(triggered()), this, SLOT( showsmplayer()) ); connect(ui.actionAbout, SIGNAL(triggered()), this, SLOT( showabout()) ); connect(ui.actionColor, SIGNAL(triggered()), this, SLOT( setStyle()) ); //connect(ui.actionSettings, SIGNAL(triggered()), this, SLOT( showSettings()) ); /** adjusted quit behaviour: trigger a warning that can be switched off in the saved config file RetroShare.conf */ connect(ui.actionQuit, SIGNAL(triggered()), this, SLOT(doQuit())); /* load the StyleSheet*/ loadStyleSheet(Rshare::stylesheet()); /* Create the Main pages and actions */ QActionGroup *grp = new QActionGroup(this); ui.stackPages->add(networkDialog = new NetworkDialog(ui.stackPages), createPageAction(QIcon(IMAGE_NETWORK2), tr("Network"), grp)); ui.stackPages->add(peersDialog = new PeersDialog(ui.stackPages), createPageAction(QIcon(IMAGE_PEERS), tr("Friends"), grp)); //PeersFeed *peersFeed = NULL; //ui.stackPages->add(peersFeed = new PeersFeed(ui.stackPages), // createPageAction(QIcon(IMAGE_PEERS), tr("Peers"), grp)); #ifdef TURTLE_HOPPING ui.stackPages->add(turtleDialog = new TurtleSearchDialog(ui.stackPages), createPageAction(QIcon(IMAGE_TURTLE), tr("Turtle"), grp)); #endif ui.stackPages->add(searchDialog = new SearchDialog(ui.stackPages), createPageAction(QIcon(IMAGE_SEARCH), tr("Search"), grp)); ui.stackPages->add(transfersDialog = new TransfersDialog(ui.stackPages), createPageAction(QIcon(IMAGE_TRANSFERS), tr("Transfers"), grp)); //TransferFeed *transferFeed = NULL; //ui.stackPages->add(transferFeed = new TransferFeed(ui.stackPages), // createPageAction(QIcon(IMAGE_LINKS), tr("Transfers"), grp)); ui.stackPages->add(sharedfilesDialog = new SharedFilesDialog(ui.stackPages), createPageAction(QIcon(IMAGE_FILES), tr("Files"), grp)); //MsgFeed *msgFeed = NULL; //ui.stackPages->add(msgFeed = new MsgFeed(ui.stackPages), // createPageAction(QIcon(IMAGE_MESSAGES), tr("Messages"), grp)); ui.stackPages->add(messagesDialog = new MessagesDialog(ui.stackPages), createPageAction(QIcon(IMAGE_MESSAGES), tr("Messages"), grp)); LinksDialog *linksDialog = NULL; #ifdef RS_RELEASE_VERSION channelsDialog = NULL; ui.stackPages->add(linksDialog = new LinksDialog(ui.stackPages), createPageAction(QIcon(IMAGE_LINKS), tr("Links Cloud"), grp)); ForumsDialog *forumsDialog = NULL; ui.stackPages->add(forumsDialog = new ForumsDialog(ui.stackPages), createPageAction(QIcon(IMAGE_FORUMS), tr("Forums"), grp)); #else channelsDialog = NULL; ui.stackPages->add(linksDialog = new LinksDialog(ui.stackPages), createPageAction(QIcon(IMAGE_LINKS), tr("Links Cloud"), grp)); ChannelFeed *channelFeed = NULL; ui.stackPages->add(channelFeed = new ChannelFeed(ui.stackPages), createPageAction(QIcon(IMAGE_CHANNELS), tr("Channels"), grp)); ForumsDialog *forumsDialog = NULL; ui.stackPages->add(forumsDialog = new ForumsDialog(ui.stackPages), createPageAction(QIcon(IMAGE_FORUMS), tr("Forums"), grp)); #endif NewsFeed *newsFeed = NULL; ui.stackPages->add(newsFeed = new NewsFeed(ui.stackPages), createPageAction(QIcon(IMAGE_NEWSFEED), tr("News Feed"), grp)); #ifdef PLUGINMGR ui.stackPages->add(pluginsPage = new PluginsPage(ui.stackPages), createPageAction(QIcon(IMAGE_PLUGINS), tr("Plugins"), grp)); #endif /* Create the toolbar */ ui.toolBar->addActions(grp->actions()); ui.toolBar->addSeparator(); connect(grp, SIGNAL(triggered(QAction *)), ui.stackPages, SLOT(showPage(QAction *))); #ifdef RS_RELEASE_VERSION #else addAction(new QAction(QIcon(IMAGE_UNFINISHED), tr("Unfinished"), ui.toolBar), SLOT(showApplWindow())); #endif /* Select the first action */ grp->actions()[0]->setChecked(true); /* also an empty list of chat windows */ messengerWindow->setChatDialog(peersDialog); // Allow to play files from SharedFilesDialog. connect(sharedfilesDialog, SIGNAL(playFiles( QStringList )), this, SLOT(playFiles( QStringList ))); connect(transfersDialog, SIGNAL(playFiles( QStringList )), this, SLOT(playFiles( QStringList ))); /** StatusBar section **/ peerstatus = new PeerStatus(); statusBar()->addWidget(peerstatus); dhtstatus = new DHTStatus(); statusBar()->addWidget(dhtstatus); natstatus = new NATStatus(); statusBar()->addWidget(natstatus); QWidget *widget = new QWidget(); QSizePolicy sizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); sizePolicy.setHorizontalStretch(0); sizePolicy.setVerticalStretch(0); sizePolicy.setHeightForWidth(widget->sizePolicy().hasHeightForWidth()); widget->setSizePolicy(sizePolicy); QHBoxLayout *horizontalLayout = new QHBoxLayout(widget); horizontalLayout->setContentsMargins(0, 0, 0, 0); horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); _hashing_info_label = new QLabel(widget) ; _hashing_info_label->setObjectName(QString::fromUtf8("label")); horizontalLayout->addWidget(_hashing_info_label); QSpacerItem *horizontalSpacer = new QSpacerItem(1000, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); horizontalLayout->addItem(horizontalSpacer); statusBar()->addPermanentWidget(widget); _hashing_info_label->hide() ; ratesstatus = new RatesStatus(); statusBar()->addPermanentWidget(ratesstatus); /******* Status Bar end ******/ /* Create the actions that will go in the tray menu */ createActions(); /****** * This is an annoying warning I get all the time... * (no help!) * * if (!QSystemTrayIcon::isSystemTrayAvailable()) QMessageBox::warning(0, tr("System tray is unavailable"), tr("System tray unavailable")); ******/ // Tray icon Menu menu = new QMenu(this); QObject::connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateMenu())); toggleVisibilityAction = menu->addAction(QIcon(IMAGE_RETROSHARE), tr("Show/Hide"), this, SLOT(toggleVisibilitycontextmenu())); menu->addSeparator(); menu->addAction(_messengerwindowAct); menu->addAction(_messagesAct); menu->addAction(_bandwidthAct); /* bandwidth only in development version */ #ifdef RS_RELEASE_VERSION #else menu->addAction(_appAct); #endif menu->addAction(_prefsAct); //menu->addAction(_smplayerAct); menu->addAction(_helpAct); menu->addSeparator(); menu->addAction(QIcon(IMAGE_MINIMIZE), tr("Minimize"), this, SLOT(showMinimized())); menu->addAction(QIcon(IMAGE_MAXIMIZE), tr("Maximize"), this, SLOT(showMaximized())); menu->addSeparator(); menu->addAction(QIcon(IMAGE_CLOSE), tr("&Quit"), this, SLOT(doQuit())); // End of Icon Menu // Create the tray icon trayIcon = new QSystemTrayIcon(this); trayIcon->setToolTip(tr("RetroShare")); trayIcon->setContextMenu(menu); trayIcon->setIcon(QIcon(IMAGE_RETROSHARE)); connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleVisibility(QSystemTrayIcon::ActivationReason))); trayIcon->show(); QTimer *timer = new QTimer(this); timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus())); timer->start(1000); }
/** Constructor */ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags) : RWindow("MainWindow", parent, flags), ui(new Ui::MainWindow) { /* Invoke the Qt Designer generated QObject setup routine */ ui->setupUi(this); _instance = this; m_bStatusLoadDone = false; isIdle = false; onlineCount = 0; notifyMenu = NULL; /* Calculate only once */ RsPeerDetails pd; if (rsPeers->getPeerDetails(rsPeers->getOwnId(), pd)) { nameAndLocation = QString("%1 (%2)").arg(QString::fromUtf8(pd.name.c_str())).arg(QString::fromUtf8(pd.location.c_str())); } setWindowTitle(tr("RetroShare %1 a secure decentralized communication platform").arg(retroshareVersion()) + " - " + nameAndLocation); /* WORK OUT IF WE"RE IN ADVANCED MODE OR NOT */ bool advancedMode = false; std::string advsetting; if (rsConfig->getConfigurationOption(RS_CONFIG_ADVANCED, advsetting) && (advsetting == "YES")) { advancedMode = true; } /* add url handler for RetroShare links */ QDesktopServices::setUrlHandler(RSLINK_SCHEME, this, "retroshareLinkActivated"); QDesktopServices::setUrlHandler("http", this, "externalLinkActivated"); QDesktopServices::setUrlHandler("https", this, "externalLinkActivated"); // Setting icons this->setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); /* Create all the dialogs of which we only want one instance */ _bandwidthGraph = new BandwidthGraph(); #ifdef UNFINISHED applicationWindow = new ApplicationWindow(); applicationWindow->hide(); #endif /** Left Side ToolBar**/ connect(ui->actionAdd_Friend, SIGNAL(triggered() ), this , SLOT( addFriend() ) ); connect(ui->actionAdd_Share, SIGNAL(triggered() ), this , SLOT( openShareManager() ) ); connect(ui->actionOptions, SIGNAL(triggered()), this, SLOT( showSettings()) ); connect(ui->actionMessenger, SIGNAL(triggered()), this, SLOT( showMessengerWindow()) ); ui->actionMessenger->setVisible(true); connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT( showabout()) ); //connect(ui->actionColor, SIGNAL(triggered()), this, SLOT( setStyle()) ); /** adjusted quit behaviour: trigger a warning that can be switched off in the saved config file RetroShare.conf */ connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(doQuit())); QList<QPair<MainPage*, QAction*> > notify; /* Create the Main pages and actions */ QActionGroup *grp = new QActionGroup(this); QAction *action; ui->stackPages->add(newsFeed = new NewsFeed(ui->stackPages), createPageAction(QIcon(IMAGE_NEWSFEED), tr("News feed"), grp)); // ui->stackPages->add(networkDialog = new NetworkDialog(ui->stackPages), // createPageAction(QIcon(IMAGE_NETWORK2), tr("Network"), grp)); ui->stackPages->add(friendsDialog = new FriendsDialog(ui->stackPages), action = createPageAction(QIcon(IMAGE_PEERS), tr("Friends"), grp)); notify.push_back(QPair<MainPage*, QAction*>(friendsDialog, action)); // ui->stackPages->add(searchDialog = new SearchDialog(ui->stackPages), // createPageAction(QIcon(IMAGE_SEARCH), tr("Search"), grp)); ui->stackPages->add(transfersDialog = new TransfersDialog(ui->stackPages), action = createPageAction(QIcon(IMAGE_TRANSFERS), tr("File sharing"), grp)); notify.push_back(QPair<MainPage*, QAction*>(transfersDialog, action)); ui->stackPages->add(chatLobbyDialog = new ChatLobbyWidget(ui->stackPages), action = createPageAction(QIcon(IMAGE_CHATLOBBY), tr("Chat Lobbies"), grp)); notify.push_back(QPair<MainPage*, QAction*>(chatLobbyDialog, action)); ui->stackPages->add(messagesDialog = new MessagesDialog(ui->stackPages), action = createPageAction(QIcon(IMAGE_MESSAGES), tr("Messages"), grp)); notify.push_back(QPair<MainPage*, QAction*>(messagesDialog, action)); ui->stackPages->add(channelFeed = new ChannelFeed(ui->stackPages), action = createPageAction(QIcon(IMAGE_CHANNELS), tr("Channels"), grp)); notify.push_back(QPair<MainPage*, QAction*>(channelFeed, action)); #ifdef BLOGS ui->stackPages->add(blogsFeed = new BlogsDialog(ui->stackPages), createPageAction(QIcon(IMAGE_BLOGS), tr("Blogs"), grp)); #endif ui->stackPages->add(forumsDialog = new ForumsDialog(ui->stackPages), action = createPageAction(QIcon(IMAGE_FORUMS), tr("Forums"), grp)); notify.push_back(QPair<MainPage*, QAction*>(forumsDialog, action)); std::cerr << "Looking for interfaces in existing plugins:" << std::endl; for(int i = 0;i<rsPlugins->nbPlugins();++i) { QIcon icon ; if(rsPlugins->plugin(i) != NULL && rsPlugins->plugin(i)->qt_page() != NULL) { if(rsPlugins->plugin(i)->qt_icon() != NULL) icon = *rsPlugins->plugin(i)->qt_icon() ; else icon = QIcon(":images/extension_48.png") ; std::cerr << " Addign widget page for plugin " << rsPlugins->plugin(i)->getPluginName() << std::endl; MainPage *pluginPage = rsPlugins->plugin(i)->qt_page(); QAction *pluginAction = createPageAction(icon, QString::fromUtf8(rsPlugins->plugin(i)->getPluginName().c_str()), grp); ui->stackPages->add(pluginPage, pluginAction); notify.push_back(QPair<MainPage*, QAction*>(pluginPage, pluginAction)); } else if(rsPlugins->plugin(i) == NULL) std::cerr << " No plugin object !" << std::endl; else std::cerr << " No plugin page !" << std::endl; } #ifndef RS_RELEASE_VERSION #ifdef PLUGINMGR ui->stackPages->add(pluginsPage = new PluginsPage(ui->stackPages), createPageAction(QIcon(IMAGE_PLUGINS), tr("Plugins"), grp)); #endif #endif #ifdef GETSTARTED_GUI MainPage *getStartedPage = NULL; if (!advancedMode) { ui->stackPages->add(getStartedPage = new GetStartedDialog(ui->stackPages), createPageAction(QIcon(IMG_HELP), tr("Getting Started"), grp)); } #endif /* Create the toolbar */ ui->toolBar->addActions(grp->actions()); connect(grp, SIGNAL(triggered(QAction *)), ui->stackPages, SLOT(showPage(QAction *))); #ifdef UNFINISHED ui->toolBar->addSeparator(); addAction(new QAction(QIcon(IMAGE_UNFINISHED), tr("Unfinished"), ui->toolBar), SLOT(showApplWindow())); #endif ui->stackPages->setCurrentIndex(Settings->getLastPageInMainWindow()); /** StatusBar section ********/ /* initialize combobox in status bar */ statusComboBox = new QComboBox(statusBar()); statusComboBox->setFocusPolicy(Qt::ClickFocus); initializeStatusObject(statusComboBox, true); QWidget *widget = new QWidget(); QHBoxLayout *hbox = new QHBoxLayout(); hbox->setMargin(0); hbox->setSpacing(6); hbox->addWidget(statusComboBox); widget->setLayout(hbox); statusBar()->addWidget(widget); peerstatus = new PeerStatus(); statusBar()->addWidget(peerstatus); natstatus = new NATStatus(); statusBar()->addWidget(natstatus); dhtstatus = new DHTStatus(); statusBar()->addWidget(dhtstatus); hashingstatus = new HashingStatus(); statusBar()->addPermanentWidget(hashingstatus); discstatus = new DiscStatus(); statusBar()->addPermanentWidget(discstatus); ratesstatus = new RatesStatus(); statusBar()->addPermanentWidget(ratesstatus); statusBar()->addPermanentWidget(new OpModeStatus()); statusBar()->addPermanentWidget(new SoundStatus()); /** Status Bar end ******/ /* Creates a tray icon with a context menu and adds it to the system's * notification area. */ createTrayIcon(); QList<QPair<MainPage*, QAction*> >::iterator notifyIt; for (notifyIt = notify.begin(); notifyIt != notify.end(); ++notifyIt) { UserNotify *userNotify = notifyIt->first->getUserNotify(this); if (userNotify) { userNotify->initialize(ui->toolBar, notifyIt->second); connect(userNotify, SIGNAL(countChanged()), this, SLOT(updateTrayCombine())); userNotifyList.push_back(userNotify); } } createNotifyIcons(); /* caclulate friend count */ updateFriends(); connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateFriends())); connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(updateFriends())); loadOwnStatus(); /* Set focus to the current page */ ui->stackPages->currentWidget()->setFocus(); idle = new Idle(); idle->start(); connect(idle, SIGNAL(secondsIdle(int)), this, SLOT(checkAndSetIdle(int))); QTimer *timer = new QTimer(this); timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus())); timer->start(1000); }
/** Constructor */ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WindowFlags flags) : RWindow("MessengerWindow", parent, flags) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); setAttribute ( Qt::WA_DeleteOnClose, true ); ui.avatar->setFrameType(AvatarWidget::STATUS_FRAME); ui.avatar->setOwnId(); connect(ui.messagelineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(savestatusmessage())); connect(NotifyQt::getInstance(), SIGNAL(ownStatusMessageChanged()), this, SLOT(loadmystatusmessage())); connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateOwnStatus(QString,int))); for (std::set<std::string>::iterator peerIt = expandedPeers.begin(); peerIt != expandedPeers.end(); ++peerIt) { ui.friendList->addPeerToExpand(*peerIt); } expandedPeers.clear(); for (std::set<RsNodeGroupId>::iterator groupIt = expandedGroups.begin(); groupIt != expandedGroups.end(); ++groupIt) { ui.friendList->addGroupToExpand(*groupIt); } expandedGroups.clear(); ui.messagelineEdit->setMinimumWidth(20); /* Initialize friend list */ QToolButton *button = new QToolButton(this); button->setIcon(QIcon(":/images/user/add_user24.png")); button->setToolTip(tr("Add a Friend")); connect(button, SIGNAL(clicked()), this, SLOT(addFriend())); ui.friendList->addToolButton(button); button = new QToolButton(this); button->setIcon(QIcon(":/images/friendsfolder24.png")); button->setToolTip(tr("Share files for your friends")); connect(button, SIGNAL(clicked()), this, SLOT(openShareManager())); ui.friendList->addToolButton(button); // load settings RsAutoUpdatePage::lockAllEvents(); ui.friendList->setColumnVisible(FriendList::COLUMN_LAST_CONTACT, false); ui.friendList->setColumnVisible(FriendList::COLUMN_IP, false); ui.friendList->setShowGroups(false); processSettings(true); RsAutoUpdatePage::unlockAllEvents(); // add self nick RsPeerDetails pd; RsPeerId ownId = rsPeers->getOwnId(); if (rsPeers->getPeerDetails(ownId, pd)) { /* calculate only once */ m_nickName = QString::fromUtf8(pd.name.c_str()); } /* Show nick and current state */ StatusInfo statusInfo; rsStatus->getOwnStatus(statusInfo); updateOwnStatus(QString::fromStdString(ownId.toStdString()), statusInfo.status); MainWindow *pMainWindow = MainWindow::getInstance(); if (pMainWindow) { QMenu *pStatusMenu = new QMenu(); pMainWindow->initializeStatusObject(pStatusMenu, true); ui.statusButton->setMenu(pStatusMenu); } loadmystatusmessage(); }
/** Initialyse Stacked Page*/ void MainWindow::initStackedPage() { /* WORK OUT IF WE"RE IN ADVANCED MODE OR NOT */ bool advancedMode = false; std::string advsetting; if (rsConfig->getConfigurationOption(RS_CONFIG_ADVANCED, advsetting) && (advsetting == "YES")) { advancedMode = true; } QList<QPair<MainPage*, QPair<QAction*, QListWidgetItem*> > > notify; /* Create the Main pages and actions */ QActionGroup *grp = new QActionGroup(this); addPage(newsFeed = new NewsFeed(ui->stackPages), grp, ¬ify); addPage(friendsDialog = new FriendsDialog(ui->stackPages), grp, ¬ify); #ifdef RS_USE_CIRCLES PeopleDialog *peopleDialog = NULL; addPage(peopleDialog = new PeopleDialog(ui->stackPages), grp, ¬ify); #endif IdDialog *idDialog = NULL; addPage(idDialog = new IdDialog(ui->stackPages), grp, ¬ify); #ifdef RS_USE_CIRCLES CirclesDialog *circlesDialog = NULL; addPage(circlesDialog = new CirclesDialog(ui->stackPages), grp, ¬ify); #endif addPage(transfersDialog = new TransfersDialog(ui->stackPages), grp, ¬ify); addPage(chatLobbyDialog = new ChatLobbyWidget(ui->stackPages), grp, ¬ify); addPage(messagesDialog = new MessagesDialog(ui->stackPages), grp, ¬ify); addPage(gxschannelDialog = new GxsChannelDialog(ui->stackPages), grp, ¬ify); addPage(gxsforumDialog = new GxsForumsDialog(ui->stackPages), grp, ¬ify); addPage(postedDialog = new PostedDialog(ui->stackPages), grp, ¬ify); #ifdef RS_USE_WIKI WikiDialog *wikiDialog = NULL; addPage(wikiDialog = new WikiDialog(ui->stackPages), grp, ¬ify); #endif #ifdef BLOGS addPage(blogsFeed = new BlogsDialog(ui->stackPages), grp, NULL); #endif std::cerr << "Looking for interfaces in existing plugins:" << std::endl; for(int i = 0;i<rsPlugins->nbPlugins();++i) { QIcon icon ; if(rsPlugins->plugin(i) != NULL && rsPlugins->plugin(i)->qt_page() != NULL) { if(rsPlugins->plugin(i)->qt_icon() != NULL) icon = *rsPlugins->plugin(i)->qt_icon() ; else icon = QIcon(":images/extension_48.png") ; std::cerr << " Addign widget page for plugin " << rsPlugins->plugin(i)->getPluginName() << std::endl; MainPage *pluginPage = rsPlugins->plugin(i)->qt_page(); pluginPage->setIconPixmap(icon); pluginPage->setPageName(QString::fromUtf8(rsPlugins->plugin(i)->getPluginName().c_str())); addPage(pluginPage, grp, ¬ify); } else if(rsPlugins->plugin(i) == NULL) std::cerr << " No plugin object !" << std::endl; else std::cerr << " No plugin page !" << std::endl; } #ifndef RS_RELEASE_VERSION #ifdef PLUGINMGR addPage(pluginsPage = new PluginsPage(ui->stackPages), grp, NULL); #endif #endif #ifdef GETSTARTED_GUI MainPage *getStartedPage = NULL; if (!advancedMode) { //ui->stackPages->add(getStartedPage = new GetStartedDialog(ui->stackPages), // createPageAction(QIcon(IMG_HELP), tr("Getting Started"), grp)); addPage(getStartedPage = new GetStartedDialog(ui->stackPages), grp, NULL); } #endif /* Create the toolbar */ ui->toolBarPage->addActions(grp->actions()); connect(grp, SIGNAL(triggered(QAction *)), ui->stackPages, SLOT(showPage(QAction *))); #ifdef UNFINISHED addAction(new QAction(QIcon(IMAGE_UNFINISHED), tr("Unfinished"), ui->toolBar), &MainWindow::showApplWindow, SLOT(showApplWindow())); ui->toolBarAction->addSeparator(); notify += applicationWindow->getNotify(); #endif /** Add icon on Action bar */ addAction(new QAction(QIcon(IMAGE_ADDFRIEND), tr("Add"), ui->toolBarAction), &MainWindow::addFriend, SLOT(addFriend())); //addAction(new QAction(QIcon(IMAGE_NEWRSCOLLECTION), tr("New"), ui->toolBarAction), &MainWindow::newRsCollection, SLOT(newRsCollection())); addAction(new QAction(QIcon(IMAGE_PREFERENCES), tr("Options"), ui->toolBarAction), &MainWindow::showSettings, SLOT(showSettings())); addAction(new QAction(QIcon(IMAGE_ABOUT), tr("About"), ui->toolBarAction), &MainWindow::showabout, SLOT(showabout())); addAction(new QAction(QIcon(IMAGE_QUIT), tr("Quit"), ui->toolBarAction), &MainWindow::doQuit, SLOT(doQuit())); QList<QPair<MainPage*, QPair<QAction*, QListWidgetItem*> > >::iterator notifyIt; for (notifyIt = notify.begin(); notifyIt != notify.end(); ++notifyIt) { UserNotify *userNotify = notifyIt->first->getUserNotify(this); if (userNotify) { userNotify->initialize(ui->toolBarPage, notifyIt->second.first, notifyIt->second.second); connect(userNotify, SIGNAL(countChanged()), this, SLOT(updateTrayCombine())); userNotifyList.push_back(userNotify); } } }
int main(){ printf("\n -------------------- DISCLAIMER ---------------------\n"); printf("|| El usuario al usar este programa, que a partir de ||\n"); printf("|| ahora sera referido como RNA, se compromete a no ||\n"); printf("|| darle un uso ilegal, ya sea para compartir ||\n"); printf("|| informacion con derechos de propiedad o por ende ||\n"); printf("|| juegos cuya funcion LAN implique el uso de un ||\n"); printf("|| servidor externo o metodo ajeno a su (del ||\n"); printf("|| usuario) propiedad. ||\n"); printf("|| ||\n"); printf("|| Pulsar cualquier tecla y continuar con el ||\n"); printf("|| programa implica la aceptacion immediata de tales ||\n"); printf("|| condiciones y la asumision total de los actos ||\n"); printf("|| realizados, eximiendo de cualquier ||\n"); printf("|| responsabilidad al creador de esta herramienta ||\n"); printf("|| de comunicacion entre plataformas PlayStation 3 ||\n"); printf("|| de Sony (c) ||\n"); printf(" -----------------------------------------------------\n\n"); system("pause"); printf("\n"); csocket = new CSocket(); //Let's rock =) sock = csocket->remoteConnect("localhost", 80); unsigned char L1 = 'b'; unsigned char L2 = 'l'; unsigned char L3 = 'i'; unsigned char L4 = 'p'; unsigned char L5 = 'i'; char path[1024] = {0}; char packet[1024] = {0}; //5 = ulen sprintf(packet, "01111600000005%.2X%.2X%.2X%.2X%.2X46f94c8de14fb36680850768ff1b7f2a", L1, L2, L3, L4, L5); BYTE crc32 = set_crc_byte(packet); printf("[C->S] %s\n", packet); sprintf(path, "/RNA/parse_packet.php?packet=%s", packet); csocket->remoteGET(sock, "localhost", path, "PKG", NULL); char *buffer = new char[1024]; memset(buffer, 0, 1024); csocket->remoteRecieve(sock, buffer, 1024); bool end = false; bool old = false; while(!end){ if(*buffer == '\n'){ if(!old) old = true; else end = true; }else if(*buffer == '\r'){} else old = false; buffer++; } printf("[S->C] %s\n", buffer); processPacket(buffer); syncTrophies(); listFriends(); printf("\nAdding Friend \"test\"\n"); addFriend(); printf("\n\n"); system("pause"); }
/** Constructor */ FriendsDialog::FriendsDialog(QWidget *parent) : RsAutoUpdatePage(1500,parent) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); if (instance == NULL) { instance = this; } last_status_send_time = 0 ; inChatCharFormatChanged = false; connect( ui.mypersonalstatusLabel, SIGNAL(clicked()), SLOT(statusmessage())); connect( ui.actionSet_your_Avatar, SIGNAL(triggered()), this, SLOT(getAvatar())); connect( ui.actionSet_your_Personal_Message, SIGNAL(triggered()), this, SLOT(statusmessage())); connect( ui.addfileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); connect( ui.actionAdd_Friend, SIGNAL(triggered()), this, SLOT(addFriend())); connect( ui.actionFriendRecommendations, SIGNAL(triggered()), this, SLOT(recommendFriends())); connect( ui.actionServicePermission, SIGNAL(triggered()), this, SLOT(servicePermission())); connect( ui.filter_lineEdit, SIGNAL(textChanged(QString)), ui.friendList, SLOT(filterItems(QString))); ui.filter_lineEdit->setPlaceholderText(tr("Search")) ; ui.filter_lineEdit->showFilterIcon(); ui.avatar->setFrameType(AvatarWidget::STATUS_FRAME); ui.avatar->setOwnId(); ui.tabWidget->setTabPosition(QTabWidget::North); ui.tabWidget->addTab(networkView = new NetworkView(),QIcon(IMAGE_NETWORK2), tr("Local network")); ui.tabWidget->addTab(networkDialog = new NetworkDialog(),QIcon(IMAGE_PEERS), tr("Known people")); //ui.tabWidget->addTab(new ProfileWidget(), tr("Profile")); //newsFeed = new NewsFeed(); //int newsFeedTabIndex = ui.tabWidget->insertTab(0, newsFeed, tr("News Feed")); //ui.tabWidget->setCurrentIndex(newsFeedTabIndex); ui.tabWidget->hideCloseButton(0); ui.tabWidget->hideCloseButton(1); ui.tabWidget->hideCloseButton(2); ui.tabWidget->hideCloseButton(3); /* get the current text and text color of the tab bar */ //newsFeedTabColor = ui.tabWidget->tabBar()->tabTextColor(newsFeedTabIndex); //newsFeedText = ui.tabWidget->tabBar()->tabText(newsFeedTabIndex); //connect(newsFeed, SIGNAL(newsFeedChanged(int)), this, SLOT(newsFeedChanged(int))); connect(ui.Sendbtn, SIGNAL(clicked()), this, SLOT(sendMsg())); connect(ui.emoticonBtn, SIGNAL(clicked()), this, SLOT(smileyWidgetgroupchat())); connect(ui.msgText,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(contextMenuMsgText(QPoint))); connect(ui.lineEdit,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(contextMenu(QPoint))); // reset text and color after removing all characters from the QTextEdit and after calling QTextEdit::clear connect(ui.lineEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(chatCharFormatChanged())); connect(ui.textboldChatButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(ui.textunderlineChatButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(ui.textitalicChatButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(ui.fontsButton, SIGNAL(clicked()), this, SLOT(chooseFont())); connect(ui.colorChatButton, SIGNAL(clicked()), this, SLOT(chooseColor())); connect(ui.actionSave_History, SIGNAL(triggered()), this, SLOT(fileSaveAs())); connect(ui.hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>))); ui.fontsButton->setIcon(QIcon(QString(":/images/fonts.png"))); mCurrentColor = Qt::black; mCurrentFont.fromString(Settings->getChatScreenFont()); colorChanged(); fontChanged(); setColorAndFont(); style.setStyleFromSettings(ChatStyle::TYPE_PUBLIC); setChatInfo(tr("Welcome to RetroShare's group chat."), QString::fromUtf8("blue")); if (rsHistory->getEnable(true)) { int messageCount = Settings->getPublicChatHistoryCount(); if (messageCount > 0) { std::list<HistoryMsg> historyMsgs; rsHistory->getMessages("", historyMsgs, messageCount); std::list<HistoryMsg>::iterator it; for (it = historyMsgs.begin(); it != historyMsgs.end(); it++) { addChatMsg(it->incoming, true, QString::fromUtf8(it->peerName.c_str()), QDateTime::fromTime_t(it->sendTime), QDateTime::fromTime_t(it->recvTime), QString::fromUtf8(it->message.c_str())); } } } QMenu *menu = new QMenu(); menu->addAction(ui.actionClear_Chat_History); menu->addAction(ui.actionDelete_Chat_History); menu->addAction(ui.actionSave_History); menu->addAction(ui.actionMessageHistory); ui.menuButton->setMenu(menu); menu = new QMenu(); menu->addAction(ui.actionAdd_Friend); menu->addAction(ui.actionAdd_Group); menu->addAction(ui.actionCreate_new_Chat_lobby); menu->addAction(ui.actionFriendRecommendations); menu->addAction(ui.actionServicePermission); menu->addSeparator(); menu->addAction(ui.actionSet_your_Avatar); menu->addAction(ui.actionSet_your_Personal_Message); ui.menutoolButton->setMenu(menu); setAcceptDrops(true); ui.lineEdit->setAcceptDrops(false); ui.hashBox->setDropWidget(this); ui.hashBox->setAutoHide(true); /* Set initial size the splitter */ QList<int> sizes; sizes << height() << 100; // Qt calculates the right sizes ui.splitter_2->setSizes(sizes); loadmypersonalstatus(); ui.displayButton->setMenu(ui.friendList->createDisplayMenu()); // load settings RsAutoUpdatePage::lockAllEvents(); ui.friendList->setShowStatusColumn(true); ui.friendList->setShowLastContactColumn(false); ui.friendList->setShowAvatarColumn(false); ui.friendList->setRootIsDecorated(true); ui.friendList->setShowGroups(true); processSettings(true); RsAutoUpdatePage::unlockAllEvents(); ui.lineEdit->installEventFilter(this); // add self nick and Avatar to Friends. RsPeerDetails pd ; if (rsPeers->getPeerDetails(rsPeers->getOwnId(),pd)) { ui.nicknameLabel->setText(PeerDefs::nameWithLocation(pd)); } /* Hide platform specific features */ #ifdef Q_WS_WIN #endif }
void LLFloaterFriends::refreshNames() { if (!sInstance) return; LLDynamicArray<LLUUID> selected_ids = getSelectedIDs(); S32 pos = mFriendsList->getScrollPos(); // get all buddies we know about LLAvatarTracker::buddy_map_t all_buddies; LLAvatarTracker::instance().copyBuddyList(all_buddies); // get all friends in list and sort by UUID std::vector<LLScrollListItem*> items = mFriendsList->getAllData(); std::sort(items.begin(), items.end(), SortFriendsByID()); std::vector<LLScrollListItem*>::iterator item_it = items.begin(); std::vector<LLScrollListItem*>::iterator item_end = items.end(); LLAvatarTracker::buddy_map_t::iterator buddy_it; for (buddy_it = all_buddies.begin() ; buddy_it != all_buddies.end(); ++buddy_it) { // erase any items that reflect residents who are no longer buddies while(item_it != item_end && buddy_it->first > (*item_it)->getValue().asUUID()) { mFriendsList->deleteItems((*item_it)->getValue()); ++item_it; } // update existing friends with new info if (item_it != item_end && buddy_it->first == (*item_it)->getValue().asUUID()) { const LLRelationship* info = buddy_it->second; if (!info) { ++item_it; continue; } S32 last_change_generation = (*item_it)->getColumn(LIST_FRIEND_UPDATE_GEN)->getValue().asInteger(); if (last_change_generation < info->getChangeSerialNum()) { // update existing item in UI updateFriendItem(mFriendsList->getItem(buddy_it->first), info); } ++item_it; } // add new friend to list else { const LLUUID& buddy_id = buddy_it->first; char first_name[DB_FIRST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ char last_name[DB_LAST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ gCacheName->getName(buddy_id, first_name, last_name); std::ostringstream fullname; fullname << first_name << " " << last_name; addFriend(fullname.str(), buddy_id); } } mFriendsList->selectMultiple(selected_ids); mFriendsList->setScrollPos(pos); }
main() { int selection = 0; int entryNum = 0; entry *phoneBook; phoneBook = (entry*)malloc(sizeof(entry)); do { printf("\n---------------------------------------------"); printf("\nPhone Book\n[1]\tAdd Friend\n[2]\tDelete Friend\n[3]\tShow Phone Book\n[4]\tSearch Phone Book\n[5]\tRandom Entry\n[6]\tAlphebetical Phone Book\n[7]\tClear Phone Book\n[8]\tSave Phone Book\n[9]\tLoad Phone Book\n[0]\tExit\n:"); scanf("%d",&selection); switch(selection) { case 1: { printf("\nYou have selected \"Add Friend\"."); addFriend(phoneBook,&entryNum); break; } case 2: { printf("\nYou have selected \"Delete Friend\"."); delFriend(phoneBook,&entryNum); break; } case 3: { printf("\nYou have selected \"Show Phone Book\"."); showBook(phoneBook,&entryNum); break; } case 4: { printf("\nYou have selected \"Search Phone Book\"."); findFriend(phoneBook,&entryNum); break; } case 5: { printf("\nYou have selected \"Random Entry\"."); randEntry(phoneBook,&entryNum); break; } case 6: { printf("\nYou have selected \"Alphabetical Phone Book\"."); alphaBook(phoneBook,&entryNum); break; } case 7: { printf("\nYou have selected \"Clear Phone Book\"."); clearBook(phoneBook,&entryNum); break; } case 8: { printf("\nYou have selected \"Save Phone Book\"."); saveBook(phoneBook,&entryNum); break; } case 9: { printf("\nYou have selected \"Load Phone Book\"."); phoneBook=loadBook(phoneBook,&entryNum); break; } case 0: { printf("\nYou have selected \"Exit\"."); printf("\nHave a nice day!"); free(phoneBook); break; } default: { printf("\nINVALID OPTION!"); break; } } }while (selection!=0); }