blob: 992ea7852ca1cd7db49d792a411b3fc6248975a7 [file] [log] [blame]
Pierre Ossman5156d5e2011-03-09 09:42:34 +00001/* Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18
19#include <assert.h>
20#include <stdio.h>
21#include <string.h>
22
23#include <FL/fl_ask.H>
24
25#include <rfb/util.h>
26#include <rfb/Password.h>
27#include <rfb/Exception.h>
28
29#include "i18n.h"
30#include "parameters.h"
31#include "UserDialog.h"
32
33using namespace rfb;
34
35UserDialog::UserDialog()
36{
37}
38
39UserDialog::~UserDialog()
40{
41}
42
43void UserDialog::getUserPasswd(char** user, char** password)
44{
45 CharArray passwordFileStr(passwordFile.getData());
46
47 assert(password);
48
49 if (!user && passwordFileStr.buf[0]) {
50 ObfuscatedPasswd obfPwd(256);
51 FILE* fp;
52
53 fp = fopen(passwordFileStr.buf, "r");
54 if (!fp)
55 throw rfb::Exception(_("Opening password file failed"));
56
57 obfPwd.length = fread(obfPwd.buf, 1, obfPwd.length, fp);
58 fclose(fp);
59
60 PlainPasswd passwd(obfPwd);
61 *password = passwd.takeBuf();
62
63 return;
64 }
65
66 if (!user) {
67 *password = strDup(fl_password(_("VNC authentication"), ""));
68 if (!*password)
69 throw rfb::Exception(_("Authentication cancelled"));
70
71 return;
72 }
73
74 fl_alert(_("NOT IMPLEMENTED!"));
75
76 *user = strDup("");
77 *password = strDup("");
78}
79
80bool UserDialog::showMsgBox(int flags, const char* title, const char* text)
81{
82 fl_message_title(title);
83 fl_message(text);
84
85 return false;
86}