Initialise 'psa' to NULL on every code path in the Pageant client
[u/mdw/putty] / macosx / osxdlg.m
index 0ea327f..295b675 100644 (file)
     int hmin = 0;
     int panelht = 0;
 
-    get_sesslist(&sl, TRUE);
-
     ctrlbox = ctrl_new_box();
-    setup_config_box(ctrlbox, &sl, FALSE /*midsession*/, aCfg.protocol,
+    setup_config_box(ctrlbox, FALSE /*midsession*/, aCfg.protocol,
                     0 /* protcfginfo */);
-    unix_setup_config_box(ctrlbox, FALSE /*midsession*/);
+    unix_setup_config_box(ctrlbox, FALSE /*midsession*/, aCfg.protocol);
 
     cfg = aCfg;                               /* structure copy */
 
  * Various special-purpose dialog boxes.
  */
 
-int askappend(void *frontend, Filename filename)
+struct appendstate {
+    void (*callback)(void *ctx, int result);
+    void *ctx;
+};
+
+static void askappend_callback(void *ctx, int result)
 {
-    return 0;                         /* FIXME */
+    struct appendstate *state = (struct appendstate *)ctx;
+
+    state->callback(state->ctx, (result == NSAlertFirstButtonReturn ? 2 :
+                                result == NSAlertSecondButtonReturn ? 1 : 0));
+    sfree(state);
+}
+
+int askappend(void *frontend, Filename filename,
+             void (*callback)(void *ctx, int result), void *ctx)
+{
+    static const char msgtemplate[] =
+       "The session log file \"%s\" already exists. "
+       "You can overwrite it with a new session log, "
+       "append your session log to the end of it, "
+       "or disable session logging for this session.";
+
+    char *text;
+    SessionWindow *win = (SessionWindow *)frontend;
+    struct appendstate *state;
+    NSAlert *alert;
+
+    text = dupprintf(msgtemplate, filename.path);
+
+    state = snew(struct appendstate);
+    state->callback = callback;
+    state->ctx = ctx;
+
+    alert = [[NSAlert alloc] init];
+    [alert setInformativeText:[NSString stringWithCString:text]];
+    [alert addButtonWithTitle:@"Overwrite"];
+    [alert addButtonWithTitle:@"Append"];
+    [alert addButtonWithTitle:@"Disable"];
+    [win startAlert:alert withCallback:askappend_callback andCtx:state];
+
+    return -1;
 }
 
 struct algstate {
@@ -320,7 +357,7 @@ static void askalg_callback(void *ctx, int result)
 {
     struct algstate *state = (struct algstate *)ctx;
 
-    state->callback(state->ctx, result == 0);
+    state->callback(state->ctx, result == NSAlertFirstButtonReturn);
     sfree(state);
 }
 
@@ -343,7 +380,7 @@ int askalg(void *frontend, const char *algtype, const char *algname,
     state->callback = callback;
     state->ctx = ctx;
 
-    alert = [NSAlert alloc];
+    alert = [[NSAlert alloc] init];
     [alert setInformativeText:[NSString stringWithCString:text]];
     [alert addButtonWithTitle:@"Yes"];
     [alert addButtonWithTitle:@"No"];
@@ -446,7 +483,27 @@ void old_keyfile_warning(void)
      */
 }
 
-void about_box(void *window)
+static void connection_fatal_callback(void *ctx, int result)
+{
+    SessionWindow *win = (SessionWindow *)ctx;
+
+    [win endSession:FALSE];
+}
+
+void connection_fatal(void *frontend, char *p, ...)
 {
-    /* FIXME */
+    SessionWindow *win = (SessionWindow *)frontend;
+    va_list ap;
+    char *msg;
+    NSAlert *alert;
+
+    va_start(ap, p);
+    msg = dupvprintf(p, ap);
+    va_end(ap);
+
+    alert = [[NSAlert alloc] init];
+    [alert setInformativeText:[NSString stringWithCString:msg]];
+    [alert addButtonWithTitle:@"Proceed"];
+    [win startAlert:alert withCallback:connection_fatal_callback
+     andCtx:win];
 }