コード例 #1
0
ファイル: LoginDialog.cpp プロジェクト: eriksjolund/st_viewer
LoginDialog::LoginDialog(QWidget *parent, Qt::WindowFlags f)
    : QDialog(parent, f)
    , m_ui(new Ui::LogIn())
    , m_completer(nullptr)
{
    setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);

    // init UI
    m_ui->setupUi(this);

    // load users and create completer
    loadUsers();

    // set the completer to the username field
    m_ui->username->setCompleter(m_completer.data());

    // connects slots
    // TODO use QDialog signals instead
    connect(m_ui->buttons->button(QDialogButtonBox::Cancel),
            SIGNAL(clicked()),
            this,
            SIGNAL(exitLogin()));
    connect(m_ui->buttons->button(QDialogButtonBox::Ok),
            SIGNAL(clicked()),
            this,
            SLOT(slotAcceptLogin()));
}
コード例 #2
0
int removeUser(char *userId)
{
        long origLen;
        int userIdLen = strlen(userId);
        char *origFile = loadUsers(&origLen);
        
        // we will be searching for the userId plus
        // a space,backslash,newline 
      
        // create a buffer big enough to hold the whole id string
        char *idBuf = malloc(sizeof(char) * (userIdLen + strlen(" \\\n") + 1));
        strcpy(idBuf,userId); // copy original
        strcat(idBuf," \\\n");
      
        // locate the original string 
        char *userIdPtr = strstr(origFile,idBuf);   
        if (userIdPtr != NULL) { // found it
                // put a null terminator at that location
                // so we can print both parts of the string,
                // skipping the userId
                *(userIdPtr) = '\0';
                
                // write back updated file
                FILE *fp = fopen(database, "w");
                if (fp != NULL) {
                        fprintf(fp,"%s",origFile);
                        fprintf(fp,"%s",userIdPtr+strlen(idBuf));
                        fclose(fp);
                }
        }

        free(idBuf); 
        free(origFile);
        return 0;
}
コード例 #3
0
ファイル: adminusers.c プロジェクト: littleyang/MaxScale
/**
 * Admin Users initialisation
 */
static void
initialise()
{
	if (admin_init)
		return;
	admin_init = 1;
	users = loadUsers();
}
コード例 #4
0
ファイル: MessageManager.cpp プロジェクト: shas19/airdcnano
void MessageManager::load(SimpleXML& aXml) {

    if (aXml.findChild("ChatFilterItems")) {
        aXml.stepIn();
        while (aXml.findChild("ChatFilterItem")) {
            WLock l(Ignorecs);
            ChatFilterItems.push_back(ChatFilterItem(aXml.getChildAttrib("Nick"), aXml.getChildAttrib("Text"),
                                      (StringMatch::Method)aXml.getIntChildAttrib("NickMethod"), (StringMatch::Method)aXml.getIntChildAttrib("TextMethod"),
                                      aXml.getBoolChildAttrib("MC"), aXml.getBoolChildAttrib("PM"), aXml.getBoolChildAttrib("Enabled")));
        }
        aXml.stepOut();
    }
    loadUsers();
}
コード例 #5
0
void SeeUsersWindow::addElem(){
	title = new QLabel("Utilisateurs", this);
	title->setAlignment(Qt::AlignCenter);
	QFont h1("", 25, QFont::Bold);

	users = new QTableWidget(this);
	loadUsers();

	ok = new QPushButton("Retour", this);
	connect(ok, SIGNAL(clicked()), this, SLOT(okSelected()));

	layout->addWidget(title, 0, 0, 1, 2);
	layout->addWidget(users, 1, 0, 1, 2);
	layout->addWidget(ok, 2, 1);
}
コード例 #6
0
bool owperGUI::changeHiveFile(string newFileName, samHive* newSam/*=NULL*/) {
    gtk_entry_set_text(GTK_ENTRY(entrySamFile), "");
    clearUsers();

    if(sam) {
        delete sam;
    }

    // see if we were passed an already-loaded SAM hive
    // this may be the case if the program was asked to check
    // a hive on startup
    if(newSam != NULL) {
        sam = newSam;
    } else {
        // no, the sam file isn't loaded yet - try to load it
        try {
            sam = new samHive(newFileName.c_str());
        }catch(owpException *exception) {
            //if sam got assigned something, delete it!
            if(sam) {
                delete sam;
                sam = NULL;
            }

            GtkWidget *errorDialog = gtk_message_dialog_new (GTK_WINDOW(this->winMain),
                                             GTK_DIALOG_DESTROY_WITH_PARENT,
                                             GTK_MESSAGE_ERROR,
                                             GTK_BUTTONS_CLOSE,
                                             "Error loading hive:\n%s",
                                             exception->errorMessage.c_str());
            gtk_dialog_run (GTK_DIALOG (errorDialog));
            gtk_widget_destroy (errorDialog);
            delete exception;
            return false;
        }
    }

    gtk_entry_set_text(GTK_ENTRY(entrySamFile), newFileName.c_str());
    loadUsers();
    return true;
}
コード例 #7
0
int addUser(char *userId)
{
        long origLen;
        char *origFile = loadUsers(&origLen);
        int userIdLen = strlen(userId);
        // check to see if the last two characters are two newlines
        // If they aren't, we will fail
        if (*(origFile+origLen-2) == '\n'
                        && *(origFile+origLen-2) == '\n') {

                // create a buffer big enough to hold the whole id string
                char *idBuf = malloc(sizeof(char) * (userIdLen + strlen(" \\\n") + 1));
                strcpy(idBuf,userId); // copy original
                strcat(idBuf," \\\n");

                // search for old so we don't add twice
                char *userIdPtr = strstr(origFile,idBuf);

                if (userIdPtr == NULL) { // not present
                        // write back updated file
                        FILE *fp = fopen(database, "w");
                        if (fp != NULL) {
                                // write all but the last newline
                                for (long i=0;i<origLen-1;i++){
                                        fprintf(fp,"%c",*(origFile+i));
                                }
                                fprintf(fp,"%s",idBuf);
                                fprintf(fp,"\n"); // final newline
                                fclose(fp);
                        }
                }
        }
        else {
                free(origFile);
                return -1;
        }
        free(origFile);
        return 0;
}
コード例 #8
0
ファイル: HttpUserUtil.cpp プロジェクト: dtbinh/dviz
HttpUserUtil::HttpUserUtil()
	: m_currentUser(0)
{
	loadUsers();
}
コード例 #9
0
ファイル: server.cpp プロジェクト: vos/qcc
Server::Server(QObject *parent) :
    QTcpServer(parent)
{
    loadUsers();
}