BearerMonitor::BearerMonitor(QWidget *parent) : QWidget(parent) { setupUi(this); #ifdef MAEMO_UI newSessionButton->hide(); deleteSessionButton->hide(); #else delete tabWidget->currentWidget(); sessionGroup->hide(); #endif updateConfigurations(); onlineStateChanged(!manager.allConfigurations(QNetworkConfiguration::Active).isEmpty()); QNetworkConfiguration defaultConfiguration = manager.defaultConfiguration(); for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) { QTreeWidgetItem *item = treeWidget->topLevelItem(i); if (item->data(0, Qt::UserRole).toString() == defaultConfiguration.identifier()) { treeWidget->setCurrentItem(item); showConfigurationFor(item); break; } } connect(&manager, SIGNAL(onlineStateChanged(bool)), this ,SLOT(onlineStateChanged(bool))); connect(&manager, SIGNAL(configurationAdded(const QNetworkConfiguration&)), this, SLOT(configurationAdded(const QNetworkConfiguration&))); connect(&manager, SIGNAL(configurationRemoved(const QNetworkConfiguration&)), this, SLOT(configurationRemoved(const QNetworkConfiguration&))); connect(&manager, SIGNAL(configurationChanged(const QNetworkConfiguration&)), this, SLOT(configurationChanged(const QNetworkConfiguration))); connect(&manager, SIGNAL(updateCompleted()), this, SLOT(updateConfigurations())); #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) connect(registerButton, SIGNAL(clicked()), this, SLOT(registerNetwork())); connect(unregisterButton, SIGNAL(clicked()), this, SLOT(unregisterNetwork())); #else // Q_OS_WIN && !Q_OS_WINRT nlaGroup->hide(); #endif connect(treeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(createSessionFor(QTreeWidgetItem*))); connect(treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(showConfigurationFor(QTreeWidgetItem*))); connect(newSessionButton, SIGNAL(clicked()), this, SLOT(createNewSession())); #ifndef MAEMO_UI connect(deleteSessionButton, SIGNAL(clicked()), this, SLOT(deleteSession())); #endif connect(scanButton, SIGNAL(clicked()), this, SLOT(performScan())); // Just in case update all configurations so that all // configurations are up to date. manager.updateConfigurations(); }
t_bool authentification(t_list **script, t_socket *client) { t_list *list; char *result; char *host; char *tmp; char cmd[1024]; char buffer[1024]; FILE *fp; char request[1024]; int session; char *database; char *sessionUsername; char *username; char *password; printf("\t\tAuth() -> Starting Execution\n"); t_list *tmpList; t_list *httpHeader; httpHeader = NULL; tmpList = *script; while (tmpList && !httpHeader) { /* printf("ALL :: %s\n", tmpList->content); */ if (tmpList->content && !strncmp(tmpList->content, "HTTP/1.1 ", strlen("HTTP/1.1 "))) httpHeader = tmpList; tmpList = tmpList->prev; } /* if (!httpHeader) */ /* { */ /* printf("\t\tCould not find httpHeader; Returning\n"); */ /* return FALSE; */ /* } */ database = setDatabase(NULL); if (!client) { if (httpHeader) httpHeader->content = HTTP_403; return FALSE; } // Is session already running ? if (checkForExistingSession(client->request, cookie_sessionID, cookie_sessionUsername)) { /* httpHeader->content = HTTP_OK; */ /* list = addToList(NULL, HTTP_OK); */ /* list = addToList(list, "\r\n"); */ printf("\t\tAthentification success; Session already running\n"); return TRUE; } // Session not running but user is trying to auth else if ((username = getParameter(client, "username")) && (password = getParameter(client, "password"))) { // Getting Parameter printf("\t\tParamaters recieved :\n"); printf("\t\t\tUsername = '******' \n", username); printf("\t\t\tPassword = '******' \n", password); setDatabase(database); snprintf(request, 1024, "SELECT * FROM users WHERE username='******'AND password='******';", username, password); setScript(request); if (!(execRequest())) { printf("\t\tAthentification failed; Returning 403\n"); /* (*script)->content = NULL; */ if (httpHeader) httpHeader->content = HTTP_403; getAuthErrorCode(403); return FALSE; } else { if (!(tmp = createNewSession(username, client->request, cookie_sessionID, cookie_sessionUsername, client))) { /* (*script)->content = NULL; */ /* (*script)->content = HTTP_403; */ if (httpHeader) httpHeader->content = HTTP_403; printf("\t\tCould not create session; Returning 403\n"); return FALSE; } else { /* t_list *next; */ /* char buffer[1024]; */ /* *buffer = '\0'; */ /* if (httpHeader) */ /* httpHeader->content = HTTP_OK; */ /* if (!(tmpList = addToList(NULL, tmp))) */ /* { */ /* perror("malloc"); */ /* exit(FAILURE); */ /* } */ /* if (httpHeader) */ /* { */ /* next = httpHeader->next; */ /* printf("next : %s\n", next->content); */ /* tmpList->prev = httpHeader; */ /* tmpList->next = next; */ /* httpHeader->next = tmpList; */ /* } */ /* else */ /* { */ /* printf("DOESN'T HAVE A HTTP HEADER\n"); */ /* insertCookie(tmp); */ /* } */ /* list = addToList(NULL, HTTP_OK); */ /* list = addToList(list, tmp); */ free(tmp); printf("\t\tAthentification success; New Session created\n"); return TRUE; } } } // session not running and missing password and or username... else { printf("\t\tAthentification failed : No session running + No auth parameters; Returning 403\n"); /* (*script)->content = NULL; */ /* (*script)->content = HTTP_403; */ if (httpHeader) httpHeader->content = HTTP_403; return FALSE; } return FALSE; /* return commitResult(list, script); */ }