// =======================================================
int CRestoreOptWindow::create(char *szDevice, char *szImageFile, COptions options)
{
  BEGIN;

  char szTemp[1024];
  
  SNPRINTF(szTemp, i18n("restore partition from image file"));
  newtCenteredWindow(78, 20, szTemp);
  
  m_labelOptions = newtLabel(1, 1, i18n("Options"));

  m_checkEraseWithNull = newtCheckbox(1, 3, i18n("Erase free blocks with zero values"), (!!options.bEraseWithNull ? 'X' : ' '), " X", NULL);
  m_checkSimulateMode = newtCheckbox(1, 2, i18n("Simulation of the restoration (nothing is written)"), (!!options.bSimulateMode ? 'X' : ' '), " X", NULL);

  m_labelFinish = newtLabel(1, 5, i18n("If finished successfully:"));
  m_radioFinishWait = newtRadiobutton(1, 6, i18n("Wait"), options.dwFinish == FINISH_WAIT, NULL);
  m_radioFinishHalt = newtRadiobutton(1, 7, i18n("Halt"), options.dwFinish == FINISH_HALT, m_radioFinishWait);
  m_radioFinishReboot = newtRadiobutton(1, 8, i18n("Reboot"), options.dwFinish == FINISH_REBOOT, m_radioFinishHalt);
  m_radioFinishQuit = newtRadiobutton(1, 9, i18n("Quit"), options.dwFinish == FINISH_QUIT, m_radioFinishReboot);
  
  addButtons();

  m_formMain = newtForm(NULL, NULL, 0);
  newtFormAddComponents(m_formMain, m_labelOptions, m_checkSimulateMode, m_checkEraseWithNull, NULL);
  newtFormAddComponents(m_formMain, m_labelFinish, m_radioFinishWait, m_radioFinishHalt, m_radioFinishReboot, m_radioFinishQuit, NULL);	
  //newtFormAddComponents(m_formMain, m_btnRestore, m_btnExit, NULL);
  addHotKeys();

  newtDrawForm(m_formMain);
  
  RETURN_int(0);	
}
// =======================================================
int CRestoreMbrWindow::create()
{
  BEGIN;

  char szTemp[2048];
  
  SNPRINTF(szTemp, "%s", i18n("Restore an MBR to the hard disk"));
  newtCenteredWindow(78, 20, szTemp);
  
  m_labelList1 = newtLabel(1, 1, i18n("Disk with the MBR to restore"));
  m_list1 = newtListbox(1, 2, 8, NEWT_FLAG_SCROLL);

  m_labelList2 = newtLabel(35, 1, i18n("Original MBR to use"));
  m_list2 = newtListbox(35, 2, 8, NEWT_FLAG_SCROLL);

  m_labelType = newtLabel(1, 12, i18n("What to restore:"));

  m_radioFull = newtRadiobutton(1, 13, i18n("The whole MBR"), true, NULL);
  m_radioBoot = newtRadiobutton(1, 14, "Only the boot loader", false, m_radioFull);
  m_radioTable = newtRadiobutton(1, 15, "Only the primary partitions table", false, m_radioBoot);

  addButtons();

  m_formMain = newtForm(NULL, NULL, 0);
  newtFormAddComponents(m_formMain, m_labelList1, m_list1, m_labelList2, 
			m_list2, m_labelType, m_radioFull, m_radioBoot, m_radioTable, NULL);
  			//m_btnOkay, m_btnCancel, NULL);
  addHotKeys();

  newtDrawForm(m_formMain);
  RETURN_int(0);	
}
Example #3
0
/* Constructs newt screens showing server certificate credentials.
 * Returns 1 if user says ok, 2 if not.
 */
static int
show_cert (X509 *cert)
{
	X509_NAME	*name;
	newtGrid	grid, serverGrid, issuerGrid, certGrid;
	newtComponent	form;

	grid = newtCreateGrid(1,2);
	certGrid = newtCreateGrid(2,2);

	/* Subject */
	name = X509_get_subject_name(cert);

	serverGrid = show_names(name);

	newtGridSetField(certGrid, 0,0, NEWT_GRID_COMPONENT,
		newtLabel(-1,-1, _("Installation Server:")),
		2, 0, 0, 0,  NEWT_ANCHOR_LEFT | NEWT_ANCHOR_TOP, 0);

	/* Issuer (CA) */
	name = X509_get_issuer_name(cert);

	issuerGrid = show_names(name);

	newtGridSetField(certGrid, 1,0, NEWT_GRID_COMPONENT,
		newtLabel(-1,-1, _("Certified by:")),
		2, 0, 0, 0,  NEWT_ANCHOR_LEFT | NEWT_ANCHOR_TOP, 0);

	newtGridSetField(certGrid, 0, 1, NEWT_GRID_SUBGRID, serverGrid,
		0, 0, 2, 0, NEWT_ANCHOR_LEFT | NEWT_ANCHOR_TOP, 0);
	newtGridSetField(certGrid, 1, 1, NEWT_GRID_SUBGRID, issuerGrid,
		0, 0, 0, 0, NEWT_ANCHOR_RIGHT | NEWT_ANCHOR_TOP, 0);

	newtGridSetField(grid, 0, 0, NEWT_GRID_SUBGRID, certGrid,
		0, 0, 0, 1, NEWT_ANCHOR_LEFT,
		NEWT_GRID_FLAG_GROWX);

	newtGridWrappedWindow(grid, _("Authenticate Installation Server"));
	form = newtForm(NULL, NULL, 0);
	newtGridAddComponentsToForm(grid, form, 1);

	newtDrawForm(form);
	newtRefresh();

	sleep(10);

	newtPopWindow();

	return 1;
}
Example #4
0
static void do_loop(int span, int looped)
{
	newtComponent form;
	newtComponent label;
	char s1[256];
	struct dahdi_maintinfo m;
	int res;
	struct newtExitStruct es;

	newtOpenWindow(20,12,40,4, s[span].desc);

	form = newtForm(NULL, NULL, 0);
	m.spanno = span;
	if (looped) {
		snprintf(s1, sizeof(s1), "Looping UP span %d...\n", span);
		m.command = DAHDI_MAINT_LOOPUP;
	} else {
		snprintf(s1, sizeof(s1), "Looping DOWN span %d...\n", span);
		m.command = DAHDI_MAINT_LOOPDOWN;
	}

	label = newtLabel(3,1,s1);
	newtFormAddComponent(form, label);
	newtPushHelpLine("Please wait...");

	newtFormSetTimer(form, 200);
	newtFormRun(form, &es);
	res = ioctl(ctl, DAHDI_MAINT, &m);
	newtFormDestroy(form);
	newtPopWindow();
	newtPopHelpLine();
}
Example #5
0
File: ncce.c Project: bmybbs/bmybbs
int
do_dict()
{
	newtComponent form, label, entry, text;
	struct newtExitStruct es;
	char *entryValue, *wordlist;
	newtCenteredWindow(70, 20, NULL);

	newtPushHelpLine("输入要查找的词,回车确定,上下键滚动,^C退出");
	label = newtLabel(2, 1, "请输入要查找的词");
	entry = newtEntry(2, 2, "", 40, &entryValue,
			  NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
	text = newtTextbox(2, 3, 66, 17, NEWT_FLAG_WRAP | NEWT_FLAG_SCROLL);
	newtTextboxSetText(text, "");
	form = newtForm(NULL, NULL, 0);
	newtFormAddHotKey(form, Ctrl('c'));
	newtFormAddHotKey(form, Ctrl('\r'));
	newtFormAddHotKey(form, Ctrl('\n'));
	newtFormAddComponents(form, label, entry, text, NULL);
	while (1) {
		newtFormRun(form, &es);
		if ((es.u.key == Ctrl('c')
		     || es.u.key == NEWT_KEY_F12)
		    && es.reason == NEWT_EXIT_HOTKEY)
			break;
		wordlist = search_dict(entryValue);
		newtTextboxSetText(text, wordlist);
	}
	newtFormDestroy(form);
	newtPopHelpLine();
	newtPopWindow();
	return 0;
}
/**
 * Open an evalcall form with title @p ttl.
 * @param ttl The title to use for the evalcall form.
 */
	void
	 open_evalcall_form(char *ttl) {

		/*@ buffers ********************************************************* */
		char *title;
		char *tmp;

		/*@ initialize ****************************************************** */
		g_isoform_old_progress = -1;
		g_mysterious_dot_counter = 0;

		assert(ttl != NULL);
		asprintf(&title, ttl);
		// BERLIOS: We need to unallocate it somewhere
		asprintf(&g_isoform_header_str, title);
		//  center_string (title, 80);
		if (g_text_mode) {
			log_msg(0, title);
		} else {
			asprintf(&tmp, title);
			/* BERLIOS: center_string is now broken replace it ! */
			//center_string(tmp, 80);
			newtPushHelpLine(tmp);
			paranoid_free(tmp);
		}
		/* BERLIOS: center_string is now broken replace it ! */
		//center_string(g_isoform_header_str, 36);
		g_isoform_starttime = get_time();
		if (g_text_mode) {
			log_msg(0, g_isoform_header_str);
		} else {
			g_isoform_header = newtLabel(1, 1, g_isoform_header_str);
			g_isoform_scale = newtScale(3, 3, 34, 100);
			//      newtOpenWindow (20, 6, 40, 7, title);      // "Please Wait");
			newtCenteredWindow(40, 7, title);
			g_isoform_main = newtForm(NULL, NULL, 0);
			g_isoform_timeline = newtLabel(1, 5, "This is the timeline");
			g_isoform_pcline = newtLabel(1, 6, "This is the pcline");
			newtFormAddComponents(g_isoform_main, g_isoform_timeline,
								  g_isoform_pcline, g_isoform_header,
								  g_isoform_scale, NULL);
			newtRefresh();
		}
		update_evalcall_form(0);
		paranoid_free(title);
	}
// =======================================================
int CSaveOptWindow::create(char *szImageFile, COptions options)
{
  BEGIN;

  char szTemp[2048];
  
  newtCenteredWindow(78, 20, i18n("save partition to image file"));
  
  m_labelCompression = newtLabel(1, 1, i18n("Compression level"));
  m_radioCompNone = newtRadiobutton(1, 2, i18n("None (very fast + very big file)"), options.dwCompression == COMPRESS_NONE, NULL);
  m_radioCompGzip = newtRadiobutton(1, 3, "Gzip (.gz: medium speed + small image file)", options.dwCompression == COMPRESS_GZIP, m_radioCompNone);
  m_radioCompBzip2 = newtRadiobutton(1, 4, "Bzip2 (.bz2: very slow + very small image file)", options.dwCompression == COMPRESS_BZIP2, m_radioCompGzip);

  m_labelOptions = newtLabel(1, 7, i18n("Options"));
  m_checkCheckBeforeSaving = newtCheckbox(1, 8, i18n("Check partition before saving"), (!!options.bCheckBeforeSaving ? 'X' : ' '), " X", NULL);
  m_checkAskDesc = newtCheckbox(1, 9, i18n("Enter description"), (!!options.bAskDesc ? 'X' : ' '), " X", NULL);
  m_checkOverwrite = newtCheckbox(1, 10, i18n("Overwrite without prompt"), (!!options.bOverwrite ? 'X' : ' '), " X", NULL);

  m_labelSplit = newtLabel(1, 12, i18n("Image split mode"));
  m_radioSplitAuto = newtRadiobutton(1, 13, i18n("Automatic split (when no space left)"), !options.qwSplitSize, NULL);
  m_radioSplitSize = newtRadiobutton(1, 14, i18n("Into files whose size is:............"), !!options.qwSplitSize, m_radioSplitAuto);
  SNPRINTF(szTemp, "%llu", (!!options.qwSplitSize) ? (options.qwSplitSize/1024/1024) : 2048);
  m_editSplitSize = newtEntry(43, 14, szTemp, 8, NULL, 0);
  m_labelSplitSizeKB = newtLabel(52, 14, i18n("MiB"));
  m_checkSplitWait = newtCheckbox(1, 15, i18n("Wait after each volume change"), (!!options.bSplitWait ? 'X' : ' '), " X", NULL);

  m_labelFinish = newtLabel(43, 7, i18n("If finished successfully:"));
  m_radioFinishWait = newtRadiobutton(43, 8, i18n("Wait"), options.dwFinish == FINISH_WAIT, NULL);
  m_radioFinishHalt = newtRadiobutton(43, 9, i18n("Halt"), options.dwFinish == FINISH_HALT, m_radioFinishWait);
  m_radioFinishReboot = newtRadiobutton(43, 10, i18n("Reboot"), options.dwFinish == FINISH_REBOOT, m_radioFinishHalt);
  m_radioFinishQuit = newtRadiobutton(43,11,i18n("Quit"), options.dwFinish == FINISH_QUIT, m_radioFinishReboot);
  m_radioFinishLast = newtRadiobutton(43,12,i18n("Last"), options.dwFinish == FINISH_LAST, m_radioFinishQuit);

  addButtons();
  
  m_formMain = newtForm(NULL, NULL, 0);
  newtFormAddComponents(m_formMain, m_labelCompression, m_labelOptions, m_labelSplit, NULL);
  newtFormAddComponents(m_formMain, m_radioCompNone, m_radioCompGzip, m_radioCompBzip2, m_checkCheckBeforeSaving, m_checkAskDesc, m_checkOverwrite, NULL);
  newtFormAddComponents(m_formMain, m_labelFinish, m_radioFinishWait, m_radioFinishHalt, m_radioFinishReboot, m_radioFinishQuit, m_radioFinishLast, NULL);	
  newtFormAddComponents(m_formMain, m_radioSplitAuto, m_radioSplitSize, m_labelSplitSizeKB, m_editSplitSize, m_checkSplitWait, NULL);
  addHotKeys();
  
  newtDrawForm(m_formMain);
  RETURN_int(0);	
}
static int show_doing(char *title, char *tmp)
{
	struct newtExitStruct es;
	newtComponent label;
	showform = newtForm(NULL, NULL, 0);
	newtCenteredWindow(70,4, title);
	label = newtLabel(3,1,tmp);
	newtFormAddComponents(showform,label, NULL);
	newtFormSetTimer(showform, 200);
	newtFormRun(showform, &es);
	return 0;
}
// ============================================================================
unsigned int CExceptionsGUI::windowError(char *szTitle, char *szText, char *szButton, char *szCurPath)
{
  BEGIN;
  //char szTemp[] = "/tmp/image";

  unsigned int nRes;
  newtComponent btnOther;
  
  newtComponent formMain = newtForm(NULL, NULL, 0);
  if (szButton)
    btnOther = newtButton(30, 15, szButton);
  else
    btnOther = newtButton(30, 15, "(none)");
  newtComponent btnOk = newtButton(10, 15, i18n("Change"));
  newtComponent btnCancel = newtButton(50, 15, i18n("Cancel"));
  newtComponent editFilename = newtEntry(5, 10, szCurPath, 45, NULL, 0);
  newtComponent labelFilename = newtLabel(5, 9, i18n("Enter new filename"));

  newtComponent labelText = newtTextbox(1, 1, 60, 7, 0);
  newtTextboxSetText(labelText, szText);

  newtComponent widgetTemp;

  newtCenteredWindow(67, 20, szTitle);
  if (szButton)
    newtFormAddComponents(formMain, editFilename, btnOk, btnOther, btnCancel,
       labelFilename, labelText, NULL);
  else
    newtFormAddComponents(formMain, editFilename, btnOk, btnCancel,
       labelFilename, labelText, NULL);

  widgetTemp = newtRunForm(formMain);

  if (widgetTemp == btnCancel)
    nRes = ERR_QUIT;
  else if (szButton && widgetTemp == btnOther)
    nRes = ERR_CONT;
  else
    {
      strncpy(szNewString, newtEntryGetValue(editFilename), 1023);
      *(szNewString+1023) = '\0';

      while (szNewString[strlen(szNewString)-1] == '/')
        szNewString[strlen(szNewString)-1] = '\0';

      nRes = ERR_RETRY;
    }
  newtFormDestroy(formMain);
  newtPopWindow();
  RETURN_WORD(nRes);
}
static int show_message(char *title, char *msg)
{
	newtComponent form;
	newtComponent label;
	newtComponent ok;
	struct newtExitStruct es;

	newtCenteredWindow(60,7, title);

	label = newtLabel(4,1,msg);
	ok = newtButton(27, 3, "OK");
	form = newtForm(NULL, NULL, 0);
	newtFormAddComponents(form, label, ok, NULL);
	newtFormRun(form, &es);
	newtPopWindow();
	newtFormDestroy(form);
	return 0;
}
Example #11
0
void init_progression_raw_newt(const char *msg, int size)
{
	size_progress = size;
	if (size) {
		actually_drawn = 0;
		newtCenteredWindow(70, 5, "Please wait...");
		form = newtForm(NULL, NULL, 0);
		newtFormAddComponent(form, newtLabel(1, 1, msg));
		scale = newtScale(1, 3, 68, size);
		newtFormAddComponent(form, scale);
		newtDrawForm(form);
		newtRefresh();
	}
	else {
		wait_message("%s", msg);
		msg_progress = msg;
	}
}
Example #12
0
static newtComponent
nmt_newt_label_build_component (NmtNewtComponent *component,
                                gboolean          sensitive)
{
	NmtNewtLabelPrivate *priv = NMT_NEWT_LABEL_GET_PRIVATE (component);
	newtComponent co;
	char *text_lc;

	text_lc = nmt_newt_locale_from_utf8 (priv->text);
	co = newtLabel (-1, -1, text_lc);
	g_free (text_lc);

	if (priv->highlight)
		newtLabelSetColors (co, NMT_NEWT_COLORSET_BAD_LABEL);
	else if (priv->style == NMT_NEWT_LABEL_PLAIN)
		newtLabelSetColors (co, NMT_NEWT_COLORSET_PLAIN_LABEL);

	return co;
}
Example #13
0
static newtComponent
nmt_newt_button_build_component (NmtNewtComponent *component,
                                 gboolean          sensitive)
{
	NmtNewtButtonPrivate *priv = NMT_NEWT_BUTTON_GET_PRIVATE (component);
	newtComponent co;
	char *label = NULL, *label_lc;

	if (sensitive) {
		label_lc = nmt_newt_locale_from_utf8 (priv->label);
		co = newtCompactButton (-1, -1, label_lc);
		g_free (label_lc);
	} else {
		label = g_strdup_printf (" <%s>", priv->label);
		label_lc = nmt_newt_locale_from_utf8 (label);
		co = newtLabel (-1, -1, label_lc);
		g_free (label_lc);
		newtLabelSetColors (co, NMT_NEWT_COLORSET_DISABLED_BUTTON);
	}

	return co;
}
Example #14
0
// =======================================================
void CInterfaceNewt::askDescription(char *szDescription, DWORD dwMaxLen)
{
  newtComponent editDesc;
  newtComponent labelText;
  newtComponent form;
  newtComponent btnOk;
  
  memset(szDescription, 0, dwMaxLen);
  
  newtCenteredWindow(65, 18, i18n("Partition description"));
  
  labelText = newtLabel(1, 1, i18n("You can enter a description of the saved partition:"));
  editDesc = newtEntry(1, 3, "", 60, NULL, NEWT_ENTRY_SCROLL);
  btnOk = newtButton(27, 13, i18n("Ok"));
  
  form = newtForm(NULL, NULL, 0);
  newtFormAddComponents(form, labelText, editDesc, btnOk, NULL);
  
  newtRunForm(form);
  newtPopWindow();	
  
  strncpy(szDescription, newtEntryGetValue(editDesc), dwMaxLen);
  newtFormDestroy(form);
}
Example #15
0
struct progressCBdata *winProgressBar(int width, int height, char *title, char *text, ...) {
    struct progressCBdata *data;
    char *buf = NULL;
    va_list args;
    int llen;
    newtComponent t, f, scale, label;

    va_start(args, text);

    if (vasprintf(&buf, text, args) != -1) {
        va_end(args);
        newtCenteredWindow(width, height, title);
        t = newtTextbox(1, 1, width - 2, height - 2, NEWT_TEXTBOX_WRAP);
        newtTextboxSetText(t, buf);
        llen = strlen(buf);
        free(buf);
        label = newtLabel(llen + 1, 1, "-");
        f = newtForm(NULL, NULL, 0);
        newtFormAddComponent(f, t);
        scale = newtScale(3, 3, width - 6, 100);
        newtFormAddComponent(f, scale);
        newtDrawForm(f);
        newtRefresh();

        if ((data = malloc(sizeof(struct progressCBdata))) == NULL) {
            logMessage(ERROR, "%s: %d: %m", __func__, __LINE__);
            abort();
        }

        data->scale = scale;
        data->label = label;
        return data;
    }

    return NULL;
}
Example #16
0
int main(void) {
    newtComponent b1, b2, r1, r2, r3, e2, e3, l1, l2, l3, scale;
    newtComponent lb, t, rsf, answer, timeLabel;
    newtComponent cs[10];
    newtComponent f, chklist, e1;
    struct callbackInfo cbis[3];
    char results[10];
    char * enr2, * enr3, * scaleVal;
    void ** selectedList;
    int i, numsel;
    char buf[20];
    const char * spinner = "-\\|/\\|/";
    const char * spinState;
    struct newtExitStruct es;

    newtInit();
    newtCls();

    newtSetSuspendCallback(suspend, NULL);
    newtSetHelpCallback(helpCallback);

    newtDrawRootText(0, 0, "Newt test program");
    newtPushHelpLine(NULL);
    newtDrawRootText(-50, 0, "More root text");

    newtOpenWindow(2, 2, 30, 10, "first window");
    newtOpenWindow(10, 5, 65, 16, "window 2");

    f = newtForm(NULL, "This is some help text", 0);
    chklist = newtForm(NULL, NULL, 0);

    b1 = newtButton(3, 1, "Exit");
    b2 = newtButton(18, 1, "Update");
    r1 = newtRadiobutton(20, 10, "Choice 1", 0, NULL);
    r2 = newtRadiobutton(20, 11, "Chc 2", 1, r1);
    r3 = newtRadiobutton(20, 12, "Choice 3", 0, r2);
    rsf = newtForm(NULL, NULL, 0);
    newtFormAddComponents(rsf, r1, r2, r3, NULL);
    newtFormSetBackground(rsf, NEWT_COLORSET_CHECKBOX);

    for (i = 0; i < 10; i++) {
	sprintf(buf, "Check %d", i);
	cs[i] = newtCheckbox(3, 10 + i, buf, ' ', NULL, &results[i]);
	newtFormAddComponent(chklist, cs[i]);
    }

    l1 = newtLabel(3, 6, "Scale:");
    l2 = newtLabel(3, 7, "Scrolls:");
    l3 = newtLabel(3, 8, "Hidden:");
    e1 = newtEntry(12, 6, "", 20, &scaleVal, 0);
    e2 = newtEntry(12, 7, "Default", 20, &enr2, NEWT_FLAG_SCROLL);
/*    e3 = newtEntry(12, 8, NULL, 20, &enr3, NEWT_FLAG_HIDDEN); */
    e3 = newtEntry(12, 8, NULL, 20, &enr3, NEWT_FLAG_PASSWORD);

    cbis[0].state = &results[0];
    cbis[0].en = e1;
    newtComponentAddCallback(cs[0], disableCallback, &cbis[0]);

    scale = newtScale(3, 14, 32, 100);

    newtFormSetHeight(chklist, 3);

    newtFormAddComponents(f, b1, b2, l1, l2, l3, e1, e2, e3, chklist, NULL);
    newtFormAddComponents(f, rsf, scale, NULL);

    lb = newtListbox(45, 1, 6, NEWT_FLAG_MULTIPLE | NEWT_FLAG_BORDER |
				NEWT_FLAG_SCROLL | NEWT_FLAG_SHOWCURSOR);
    newtListboxAppendEntry(lb, "First", (void *) 1);
    newtListboxAppendEntry(lb, "Second", (void *) 2);
    newtListboxAppendEntry(lb, "Third", (void *) 3);
    newtListboxAppendEntry(lb, "Fourth", (void *) 4);
    newtListboxAppendEntry(lb, "Sixth", (void *) 6);
    newtListboxAppendEntry(lb, "Seventh", (void *) 7);
    newtListboxAppendEntry(lb, "Eighth", (void *) 8);
    newtListboxAppendEntry(lb, "Ninth", (void *) 9);
    newtListboxAppendEntry(lb, "Tenth", (void *) 10);

    newtListboxInsertEntry(lb, "Fifth", (void *) 5, (void *) 4);
    newtListboxInsertEntry(lb, "Eleventh", (void *) 11, (void *) 10);
    newtListboxDeleteEntry(lb, (void *) 11);

    spinState = spinner;
    timeLabel = newtLabel(45, 8, "Spinner: -");

    t = newtTextbox(45, 10, 17, 5, NEWT_FLAG_WRAP);
    newtTextboxSetText(t, "This is some text does it look okay?\nThis should be alone.\nThis shouldn't be printed");

    newtFormAddComponents(f, lb, timeLabel, t, NULL);
    newtRefresh();
    newtFormSetTimer(f, 200);

    do {
	newtFormRun(f, &es);

	if (es.reason == NEWT_EXIT_COMPONENT && es.u.co == b2) {
	    newtScaleSet(scale, atoi(scaleVal));
	    newtRefresh();
	    answer = NULL;
	} else if (es.reason == NEWT_EXIT_TIMER) {
	    spinState++;
	    if (!*spinState) spinState = spinner;
	    sprintf(buf, "Spinner: %c", *spinState);
	    newtLabelSetText(timeLabel, buf);
	}
    } while (es.reason != NEWT_EXIT_COMPONENT || es.u.co == b2);

    scaleVal = strdup(scaleVal);
    enr2 = strdup(enr2);
    enr3 = strdup(enr3);

    selectedList = newtListboxGetSelection(lb, &numsel);

    newtFormDestroy(f);

    newtPopWindow();
    newtPopWindow();
    newtFinished();

    printf("got string 1: %s\n", scaleVal);
    printf("got string 2: %s\n", enr2);
    printf("got string 3: %s\n", enr3);

    if(selectedList) {
	printf("\nSelected listbox items:\n");
	for(i = 0; i < numsel; i++)
	    puts(selectedList[i]);
    }

    return 0;
}
Example #17
0
static void show_spans(void)
{
	newtComponent form;
	newtComponent quit;
	newtComponent label;
	newtComponent sel;

	
	struct newtExitStruct es;
	
	
	quit = newtButton(50,14,"Quit");
	sel = newtButton(10,14,"Select");
	
	spans = newtListbox(5, 2, 10, NEWT_FLAG_SCROLL);
	newtListboxSetWidth(spans, 65);
	
	label = newtLabel(5,1,"Alarms          Span");
	
	newtCenteredWindow(72,18, "DAHDI Telephony Interfaces");
	form = newtForm(NULL, NULL, 0);
	
	newtFormSetTimer(form, 200);
	
	newtFormAddComponents(form, spans, sel, quit, label, NULL);

	newtComponentAddCallback(spans, sel_callback, NULL);

	newtFormAddHotKey(form, NEWT_KEY_F1);
	newtFormAddHotKey(form, NEWT_KEY_F10);
	
	for(;;) {
		/* Wait for user to select something */
		do {
			add_cards(spans);
			newtFormRun(form, &es);
		} while(es.reason == NEWT_EXIT_TIMER);

		switch(es.reason) {
		case NEWT_EXIT_COMPONENT:
			if (es.u.co == quit) {
				/* Quit if appropriate */
				newtFormDestroy(form);
				return;
			} else if (es.u.co == sel) {
				show_span(-1);
			}
			break;
		case NEWT_EXIT_HOTKEY:
			switch(es.u.key) {
			case NEWT_KEY_F1:
				show_span(-1);
				break;
			case NEWT_KEY_F10:
				newtFormDestroy(form);
				return;
			}
			break;
		default:
			break;
		}
	}
}
Example #18
0
static void show_span(int span)
{
	newtComponent form;
	newtComponent back;
	newtComponent loop;
	newtComponent label;
	newtComponent bitbox;
	newtComponent inuse;
	newtComponent levels;
	newtComponent bpvcount;
	newtComponent alarms;
	newtComponent syncsrc;
	newtComponent irqmisses;
	
	char s1[] = "         1111111111222222222233";
	char s2[] = "1234567890123456789012345678901";
	int x;
	int looped = 0;
	struct newtExitStruct es;

	void *ss;
	char info2[256];

	if (span < 0) {
		/* Display info on a span */
		ss = newtListboxGetCurrent(spans);
		if (ss) {
			span = (long)(ss);
		}
	}

	snprintf(info2, sizeof(info2), "%-59s            F10=Back", s[span].desc);
	newtOpenWindow(10,2,60,20, s[span].desc);
	newtPushHelpLine(info2);

	back = newtButton(48,8,"Back");
	loop = newtButton(48,14,"Loop");
	form = newtForm(NULL, NULL, 0);

	newtFormAddComponents(form, back, loop, NULL);

	span_max_chan_pos = s[span].totalchans;
	for (x=0;x<DAHDI_MAX_CHANNELS;x++) {
		DAHDI_PARAMS zp;
		int res;
		memset(&zp, 0, sizeof(zp));
		zp.channo = x;
		res = ioctl(ctl, DAHDI_GET_PARAMS, &zp);
		if (!res && zp.spanno == span && zp.chanpos > span_max_chan_pos )
			span_max_chan_pos = zp.chanpos;
	}

	if (span_max_chan_pos > 32)
		span_max_chan_pos = 32;

	s1[span_max_chan_pos] = '\0';
	s2[span_max_chan_pos] = '\0';

	bitbox = newtTextbox(8,10,span_max_chan_pos,9,0);
	newtFormAddComponent(form, bitbox);

	label = newtLabel(8,8,s1);
	newtFormAddComponent(form, label);

	label = newtLabel(8,9,s2);
	newtFormAddComponent(form, label);

	newtFormAddHotKey(form, NEWT_KEY_F10);
	newtFormSetTimer(form, 200);

	label = newtLabel(4,10,"TxA");
	newtFormAddComponent(form, label);

	label = newtLabel(4,11,"TxB");
	newtFormAddComponent(form, label);

	label = newtLabel(4,12,"TxC");
	newtFormAddComponent(form, label);

	label = newtLabel(4,13,"TxD");
	newtFormAddComponent(form, label);

	label = newtLabel(4,15,"RxA");
	newtFormAddComponent(form, label);

	label = newtLabel(4,16,"RxB");
	newtFormAddComponent(form, label);

	label = newtLabel(4,17,"RxC");
	newtFormAddComponent(form, label);

	label = newtLabel(4,18,"RxD");
	newtFormAddComponent(form, label);
	
	
	label = newtLabel(4,7,"Total/Conf/Act: ");
	newtFormAddComponent(form, label);
	
	inuse = newtTextbox(24,7,12,1,0);
	newtFormAddComponent(form, inuse);

	label = newtLabel(4,6,"Tx/Rx Levels: ");
	newtFormAddComponent(form, label);

	levels = newtTextbox(24,6,30,1,0);
	newtFormAddComponent(form, levels);
	
	label = newtLabel(4,5,"Bipolar Viol: ");
	newtFormAddComponent(form, label);

	bpvcount = newtTextbox(24,5,30,1,0);
	newtFormAddComponent(form, bpvcount);
	
	label = newtLabel(4,4,"IRQ Misses: ");
	newtFormAddComponent(form, label);

	irqmisses = newtTextbox(24,4,30,1,0);
	newtFormAddComponent(form, irqmisses);

	label = newtLabel(4,3,"Sync Source: ");
	newtFormAddComponent(form, label);

	syncsrc = newtTextbox(24,3,30,1,0);
	newtFormAddComponent(form, syncsrc);

	label = newtLabel(4,2,"Current Alarms: ");
	newtFormAddComponent(form, label);

	alarms = newtTextbox(24,2,30,1,0);
	newtFormAddComponent(form, alarms);
	
	for(;;) {
		/* Wait for user to select something */
		do {
			add_cards(NULL);
			show_bits(span, bitbox, inuse, levels, bpvcount, alarms, syncsrc, irqmisses);
			newtFormRun(form, &es);
		} while(es.reason == NEWT_EXIT_TIMER);
		switch(es.reason) {
		case NEWT_EXIT_COMPONENT:
			if (es.u.co == loop) {
				looped = !looped;
				do_loop(span, looped);
				newtFormSetTimer(form, 200);
			}
			if (es.u.co == back) {
				goto out;
			}
			break;
		case NEWT_EXIT_HOTKEY:
			switch(es.u.key) {
#if 0
			case NEWT_KEY_F1:
				show_span(-1);
				break;
#endif				
			case NEWT_KEY_F10:
				goto out;
			}
			break;
		default:
			break;
		}
	}	

out:	
	newtFormDestroy(form);
	newtPopWindow();
	newtPopHelpLine();
	span_max_chan_pos = 0;
}
// =======================================================
int CRestoringWindow::create(char *szDevice, char *szImageFile, QWORD qwCurPartSize, DWORD dwCompressionMode, char *szOriginalDevice, char *szFileSystem, tm dateCreate, QWORD qwOrigPartSize, COptions * options)
{
  BEGIN;
  
  char szTemp[2048];
  char szTemp2[2048];
 
  if (options->bSimulateMode)
    SNPRINTF(szTemp, i18n("simulate partition restoration from image file"));
  else
    SNPRINTF(szTemp, i18n("restore partition from image file"));
  newtCenteredWindow(78, 20, szTemp);
  
  SNPRINTF(szTemp, i18n("Partition to restore:.............%s"), szDevice);
  m_labelPartition = newtLabel(1, 0, szTemp);
  
  SNPRINTF(szTemp, i18n("Size of partition to restore:.....%s = %llu bytes"), formatSize(qwCurPartSize, szTemp2), qwCurPartSize);
  m_labelPartitionSize = newtLabel(1, 1, szTemp);
  
  SNPRINTF(szTemp, i18n("Image file to use.................%s"), szImageFile);
  m_labelImageFile = newtLabel(1, 2, szTemp);
  
  SNPRINTF(szTemp, i18n("File system:......................%s"), szFileSystem);
  m_labelFS = newtLabel(1, 3, szTemp);

  m_labelCompression = newtLabel(1, 4, "");

  SNPRINTF(szTemp, i18n("Partition was on device:..........%s\n"), szOriginalDevice);
  m_labelOldDevice = newtLabel(1, 5, szTemp);

  SNPRINTF(szTemp, i18n("Image created on:.................%s\n"), asctime(&dateCreate));
  m_labelDate = newtLabel(1, 6, szTemp);

  SNPRINTF(szTemp, i18n("Size of the original partition:...%s = %llu bytes"), formatSize(qwOrigPartSize, szTemp2), qwOrigPartSize);
  m_labelOriginalPartitionSize = newtLabel(1, 7, szTemp);

  // stats
  m_labelStatsTime = newtLabel(1, 9, "");
  m_labelStatsTimeRemaining = newtLabel(1, 10, "");
  m_labelStatsSpeed = newtLabel(1, 11, "");
  m_labelStatsSpace = newtLabel(1, 12, "");

  m_progressRestoring = newtScale(1, 18, 70, 100);
  m_labelPercent = newtLabel(72, 18, "");
  
  m_formMain = newtForm(NULL, NULL, 0);
  newtFormAddComponents(m_formMain, m_labelPartition, m_labelPartitionSize, m_labelImageFile, m_labelFS, m_labelCompression, NULL);
  newtFormAddComponents(m_formMain, m_labelOldDevice, m_labelDate, m_labelOriginalPartitionSize, NULL);
  newtFormAddComponents(m_formMain, m_labelStatsTime, m_labelStatsTimeRemaining, m_labelStatsSpeed, m_labelStatsSpace, NULL);
  newtFormAddComponents(m_formMain, m_progressRestoring, m_labelPercent, NULL);
  
  newtDrawForm(m_formMain);
  newtRefresh();

  RETURN_int(0);
}
Example #20
0
int doMediaCheck(char *file, char *descr) {
    struct progressCBdata data;
    newtComponent t, f, scale, label;
    int rc;
    int dlen;
    int llen;
    char tmpstr[1024];

    if (access(file, R_OK) < 0) {
	newtWinMessage(_("Error"), _("OK"), _("Unable to find install image "
					      "%s"), file);
	return -1;
    }

    if (descr)
	snprintf(tmpstr, sizeof(tmpstr), _("Checking \"%s\"..."), descr);
    else
	snprintf(tmpstr, sizeof(tmpstr), _("Checking media now..."));

    dlen = strlen(tmpstr);
    if (dlen > 65)
	dlen = 65;

    newtCenteredWindow(dlen+8, 6, _("Media Check"));
    t = newtTextbox(1, 1, dlen+4, 3, NEWT_TEXTBOX_WRAP);

    newtTextboxSetText(t, tmpstr);
    llen = strlen(tmpstr);

    label = newtLabel(llen+1, 1, "-");
    f = newtForm(NULL, NULL, 0);
    newtFormAddComponent(f, t);
    scale = newtScale(3, 3, dlen, 100);
    newtFormAddComponent(f, scale);

    newtDrawForm(f);
    newtRefresh();

    data.scale = scale;
    data.label = label;

    rc = mediaCheckFile(file, progressCallback, &data);

    newtFormDestroy(f);
    newtPopWindow();

    if (rc == -1) {
	logMessage(WARNING, "mediacheck: %s (%s) has no checksum info", file, descr);
	newtWinMessage(_("Error"), _("OK"),
		       _("Unable to read the disc checksum from the "
			 "primary volume descriptor.  This probably "
			 "means the disc was created without adding the "
			 "checksum."));
    } else if (rc == 0) {
        logMessage(ERROR, "mediacheck: %s (%s) FAILED", file, descr);
        newtWinMessage(_("Error"), _("OK"),
                       _("The image which was just tested has errors. "
                         "This could be due to a "
                         "corrupt download or a bad disc.  "
                         "If applicable, please clean the disc "
                         "and try again.  If this test continues to fail you "
                         "should not continue the install."));
    } else if (rc > 0) {
        logMessage(INFO, "mediacheck: %s (%s) PASSED", file, descr);
        newtWinMessage(_("Success"), _("OK"),
                       _("The image which was just tested was successfully "
                         "verified.  It should be OK to install from this "
                         "media.  Note that not all media/drive errors can "
                         "be detected by the media check."));
    }


    return rc;
}
Example #21
0
/* only supports up to 50 buttons and entries -- shucks! */
static int mynewtWinEntries(char * title, char * text, int suggestedWidth, int flexDown, 
			    int flexUp, int dataWidth, void (*callback_func)(char ** strings),
			    struct newtWinEntry * items, char * button1, ...) {
	newtComponent buttons[50], result, form, textw;
	newtGrid grid, buttonBar, subgrid;
	int numItems;
	int rc, i;
	int numButtons;
	char * buttonName;
	newtComponent entries[50];

	va_list args;
	
	textw = newtTextboxReflowed(-1, -1, text, suggestedWidth, flexDown,
				    flexUp, 0);
	
	for (numItems = 0; items[numItems].text; numItems++); 
	
	buttonName = button1, numButtons = 0;
	va_start(args, button1);
	while (buttonName) {
		buttons[numButtons] = newtButton(-1, -1, buttonName);
		numButtons++;
		buttonName = va_arg(args, char *);
	}
	
	va_end(args);
	
	buttonBar = newtCreateGrid(numButtons, 1);
	for (i = 0; i < numButtons; i++) {
		newtGridSetField(buttonBar, i, 0, NEWT_GRID_COMPONENT, 
				 buttons[i],
				 i ? 1 : 0, 0, 0, 0, 0, 0);
	}

	if (callback_func) {
		callback_real_function = callback_func;
		entries[numItems] = NULL;
	}
	else
		callback_real_function = NULL;
	
	subgrid = newtCreateGrid(2, numItems);
	for (i = 0; i < numItems; i++) {
		newtComponent entr = newtEntry(-1, -1, items[i].value ? 
					       *items[i].value : NULL, dataWidth,
					       (const char**)items[i].value, items[i].flags);

		newtGridSetField(subgrid, 0, i, NEWT_GRID_COMPONENT,
				 newtLabel(-1, -1, items[i].text),
				 0, 0, 0, 0, NEWT_ANCHOR_LEFT, 0);
		newtGridSetField(subgrid, 1, i, NEWT_GRID_COMPONENT,
				 entr,
				 1, 0, 0, 0, 0, 0);
		if (callback_func) {
			entries[i] = entr;
			newtComponentAddCallback(entr, default_callback, entries);
		}
	}
	
	
	grid = newtCreateGrid(1, 3);
	form = newtForm(NULL, 0, 0);
	newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, textw, 
			 0, 0, 0, 0, NEWT_ANCHOR_LEFT, 0);
	newtGridSetField(grid, 0, 1, NEWT_GRID_SUBGRID, subgrid, 
			 0, 1, 0, 0, 0, 0);
	newtGridSetField(grid, 0, 2, NEWT_GRID_SUBGRID, buttonBar, 
			 0, 1, 0, 0, 0, NEWT_GRID_FLAG_GROWX);
	newtGridAddComponentsToForm(grid, form, 1);
	newtGridWrappedWindow(grid, title);
	newtGridFree(grid, 1);
	
	result = newtRunForm(form);
	
	for (rc = 0; rc < numItems; rc++)
		*items[rc].value = strdup(*items[rc].value);
	
	for (rc = 0; result != buttons[rc] && rc < numButtons; rc++);
	if (rc == numButtons) 
		rc = 0; /* F12 */
	else 
		rc++;
	
	newtFormDestroy(form);
	newtPopWindow();
	
	return rc;
}
Example #22
0
// =======================================================
int CInterfaceNewt::guiInitMainWindow(char *szDevice, char *szImageFile, char *szNetworkIP, DWORD *dwServerPort, bool *bSsl)
{
  newtComponent formMain, btnContinue, btnExit, btnAbout;
  newtComponent labelPartition, labelImage, editPartition, editImage, btnImage;
  newtComponent widgetTemp, labelAction, radioSave, radioRestore, radioMbr;
  newtComponent checkNetwork, labelNetwork, labelPort, editNetwork, editPort, checkSsl;
  newtExitStruct event;
  char szTemp[1024];
  int nAction;
  int nRes;

  showDebug(8, "guiInitMainWindow\n");
  
  SNPRINTF(szTemp, "Partition Image %s", PACKAGE_VERSION);
  newtCenteredWindow(67, 20, szTemp);
  
  labelPartition = newtLabel(1, 0, i18n("* Partition to save/restore"));
  editPartition = newtListbox(3, 1, 7, NEWT_FLAG_SCROLL);
  labelImage = newtLabel(1, 9, i18n("* Image file to create/use"));
  editImage = newtEntry(3, 10, szImageFile, 59, NULL, NEWT_FLAG_SCROLL);
  btnImage = newtCompactButton(62, 10, "*");

  labelAction = newtLabel(1, 12, i18n("Action to be done:"));
  radioSave = newtRadiobutton(1, 13, i18n("Save partition into a new image file"), true, NULL);
  radioRestore = newtRadiobutton(1, 14, i18n("Restore partition from an image file"), false, radioSave);
  radioMbr = newtRadiobutton(1, 15, i18n("Restore an MBR from the image file"), false, radioRestore);
  
  checkNetwork = newtCheckbox(1, 17, i18n("Connect to server"), (!!(*szNetworkIP) ? 'X' : ' '), " X", NULL);
#ifdef HAVE_SSL
  checkSsl = newtCheckbox(5, 19, i18n("Encrypt data on the network with SSL"), (*bSsl ? 'X' : ' '), " X", NULL);
#else
  #ifdef MUST_LOGIN
    checkSsl = newtLabel(5, 19,i18n("SSL disabled at compile time"));
  #else
    checkSsl = newtLabel(5, 19,i18n("SSL&login disabled at compile time"));
  #endif
#endif
  labelNetwork = newtLabel(5, 18, i18n("IP/name of the server:"));
  editNetwork = newtEntry(28, 18, szNetworkIP, 25, NULL, 0);
  labelPort = newtLabel(54, 18, i18n("Port:"));
  SNPRINTF(szTemp, "%u", *dwServerPort);
  editPort = newtEntry(60, 18, szTemp, 6, NULL, 0);
  
  btnContinue = newtCompactButton(50, 12, i18n("Next (F5)"));
  btnAbout = newtCompactButton(50, 14, i18n("About"));
  btnExit = newtCompactButton(50, 16, i18n("Exit (F6)"));

  nRes = fillPartitionList(editPartition);
  if (nRes == -1)
    RETURN_int(-1);
  
  formMain = newtForm(NULL, NULL, 0);
  newtFormAddComponents(formMain, labelPartition, labelImage, editPartition, editImage,
                        btnImage, labelAction, radioSave, radioRestore, radioMbr, checkNetwork,
			labelNetwork, editNetwork, labelPort, editPort, checkSsl, 
			btnContinue, btnAbout, btnExit, NULL);
  newtFormAddHotKey(formMain, KEY_EXIT); // Exit
  newtFormAddHotKey(formMain, KEY_OKAY); // Okay

 begin:
  /*widgetTemp = */newtFormRun(formMain, &event);
  widgetTemp = newtFormGetCurrent(formMain);

  if (((event.reason == event.NEWT_EXIT_HOTKEY) && (event.u.key == KEY_EXIT)) || ((event.reason == event.NEWT_EXIT_COMPONENT) && (widgetTemp == btnExit))) 
  //if(widgetTemp == btnExit)
    return OPERATION_EXIT;

  if ((event.reason == event.NEWT_EXIT_COMPONENT) && (widgetTemp == btnAbout))
    {	
      showAboutDialog();
      goto begin;
    }

  if ((event.reason == event.NEWT_EXIT_COMPONENT) && (widgetTemp == btnImage))
    {	
      char *fs_;
      fs_=filesel(newtEntryGetValue(editImage));
      if(fs_) {
        newtEntrySet(editImage, fs_, 1);
//        free(fs_);
        }
      
      goto begin;
    }

  
  if (strcmp(newtEntryGetValue(editImage), "") == 0) // if "image" field empty
    {	
      msgBoxError(i18n("The \"Image\" field is empty. Cannot continue"));
      goto begin;
    }
  
  if (newtCheckboxGetValue(checkNetwork) == 'X')
    {
      if (!(*newtEntryGetValue(editNetwork)))	
	{
	  msgBoxError(i18n("The \"Server IP/Name\" field is empty. Cannot continue"));
	  goto begin;
	}
      
      if (!atoi((char*)newtEntryGetValue(editPort)))
	{
	  msgBoxError(i18n("The \"Server Port\" field is not a valid integer. Cannot continue"));
	  goto begin;
	}
      
    }
  
  // get device
  strcpy(szDevice, (char*)newtListboxGetCurrent(editPartition));
  
  // image file
  strcpy(szImageFile, newtEntryGetValue(editImage));
  
  // network
  if (newtCheckboxGetValue(checkNetwork) == 'X') // If network is activated
    {
      strcpy(szNetworkIP, (char*)newtEntryGetValue(editNetwork));
      *dwServerPort = atoi((char*)newtEntryGetValue(editPort));
#ifdef HAVE_SSL
      *bSsl = (newtCheckboxGetValue(checkSsl) == 'X');
#endif
    }
  else // no network
    {
      *szNetworkIP = 0;
      *dwServerPort = OPTIONS_DEFAULT_SERVERPORT;	
    }
  
  nAction = 0;
  
  if (newtRadioGetCurrent(radioRestore) == radioSave)
    {	
      nAction = OPERATION_SAVE;
    }
  else if (newtRadioGetCurrent(radioRestore) == radioRestore)
    {
      nAction = OPERATION_RESTORE;
    }
  else if (newtRadioGetCurrent(radioRestore) == radioMbr)
    {
      nAction = OPERATION_RESTMBR;
    }
  
  newtFormDestroy(formMain);
  newtPopWindow();
  
  return nAction;
}
static int login(char *hostname)
{
	newtComponent form;
	newtComponent cancel;
	newtComponent login;
	newtComponent username;
	newtComponent password;
	newtComponent label;
	newtComponent ulabel;
	newtComponent plabel;
	const char *user;
	const char *pass;
	struct message *m;
	struct newtExitStruct es;
	char tmp[55];
	struct hostent *hp;
	int res = -1;
	
	session.fd = socket(AF_INET, SOCK_STREAM, 0);
	if (session.fd < 0) {
		snprintf(tmp, sizeof(tmp), "socket() failed: %s\n", strerror(errno));
		show_message("Socket failed", tmp);
		return -1;
	}
	
	snprintf(tmp, sizeof(tmp), "Looking up %s\n", hostname);
	show_doing("Connecting....", tmp);
	
	
	hp = gethostbyname(hostname);
	if (!hp) {
		snprintf(tmp, sizeof(tmp), "No such address: %s\n", hostname);
		show_message("Host lookup failed", tmp);
		return -1;
	}
	hide_doing();
	snprintf(tmp, sizeof(tmp), "Connecting to %s", hostname);
	show_doing("Connecting...", tmp);

	session.sin.sin_family = AF_INET;
	session.sin.sin_port = htons(DEFAULT_MANAGER_PORT);
	memcpy(&session.sin.sin_addr, hp->h_addr, sizeof(session.sin.sin_addr));

	if (connect(session.fd,(struct sockaddr*)&session.sin, sizeof(session.sin))) {
		snprintf(tmp, sizeof(tmp), "%s failed: %s\n", hostname, strerror(errno));
		show_message("Connect Failed", tmp);
		return -1;
	}
	
	hide_doing();
	
	login = newtButton(5, 6, "Login");
	cancel = newtButton(25, 6, "Cancel");
	newtCenteredWindow(40, 10, "Asterisk Manager Login");
	snprintf(tmp, sizeof(tmp), "Host:     %s", hostname);
	label = newtLabel(4,1, tmp);
	
	ulabel = newtLabel(4,2,"Username:"******"Password:"******"", 20, _NEWT_CAST &user, 0);
	password = newtEntry(14, 3, "", 20, _NEWT_CAST &pass, NEWT_FLAG_HIDDEN);
	
	form = newtForm(NULL, NULL, 0);
	newtFormAddComponents(form, username, password, login, cancel, label, ulabel, plabel,NULL);
	newtFormRun(form, &es);
	if (es.reason == NEWT_EXIT_COMPONENT) {
		if (es.u.co == login) {
			snprintf(tmp, sizeof(tmp), "Logging in '%s'...", user);
			show_doing("Logging in", tmp);
			/* Check to see if the remote host supports MD5 Authentication */
			manager_action("Challenge", "AuthType: MD5\r\n");
			m = wait_for_response(10000);
			if (m && !strcasecmp(get_header(m, "Response"), "Success")) {
				char *challenge = get_header(m, "Challenge");
				int x;
				int len = 0;
				char md5key[256] = "";
				struct MD5Context md5;
				unsigned char digest[16];
				MD5Init(&md5);
				MD5Update(&md5, (unsigned char *)challenge, strlen(challenge));
				MD5Update(&md5, (unsigned char *)pass, strlen(pass));
				MD5Final(digest, &md5);
				for (x=0; x<16; x++)
					len += sprintf(md5key + len, "%2.2x", digest[x]);
				manager_action("Login",
						"AuthType: MD5\r\n"
						"Username: %s\r\n"
						"Key: %s\r\n",
						user, md5key);
				m = wait_for_response(10000);
				hide_doing();
				if (!strcasecmp(get_header(m, "Response"), "Success")) {
					res = 0;
				} else {
					show_message("Login Failed", get_header(m, "Message"));
				}
			} else {
				memset(m, 0, sizeof(m));
				manager_action("Login", 
					"Username: %s\r\n"
					"Secret: %s\r\n",
						user, pass);
				m = wait_for_response(10000);
				hide_doing();
				if (m) {
					if (!strcasecmp(get_header(m, "Response"), "Success")) {
						res = 0;
					} else {
						show_message("Login Failed", get_header(m, "Message"));
					}
				}
			}
		}
	}
	newtFormDestroy(form);
	return res;
}
Example #24
0
/* setup hard drive based install from a partition with a filesystem and
 * ISO images on that filesystem
 */
char * mountHardDrive(struct installMethod * method,
		      char * location, struct loaderData_s * loaderData) {
    int rc;
    int i;

    newtComponent listbox, label, dirEntry, form, okay, back, text;
    struct newtExitStruct es;
    newtGrid entryGrid, grid, buttons;

    int done = 0;
    char * dir = strdup("");
    char * tmpDir;
    char * url = NULL;
    char * buf, *substr;
    int numPartitions;

    char **partition_list;
    char *selpart;
    char *kspartition = NULL, *ksdirectory = NULL;

    /* handle kickstart/stage2= data first if available */
    if (loaderData->method == METHOD_HD && loaderData->stage2Data) {
        kspartition = ((struct hdInstallData *)loaderData->stage2Data)->partition;
        ksdirectory = ((struct hdInstallData *)loaderData->stage2Data)->directory;
        logMessage(INFO, "partition is %s, dir is %s", kspartition, ksdirectory);

        /* if exist, duplicate */
        if (kspartition)
            kspartition = strdup(kspartition);
        if (ksdirectory) {
            ksdirectory = strdup(ksdirectory);
        } else {
            ksdirectory = strdup("/images/install.img");
        }

        if (!kspartition || !ksdirectory) {
            logMessage(ERROR, "missing partition or directory specification");
            loaderData->method = -1;

            if (loaderData->inferredStage2)
                loaderData->invalidRepoParam = 1;
        } else {
            /* if we start with /dev, strip it (#121486) */
            char *kspart = kspartition;
            if (!strncmp(kspart, "/dev/", 5))
                kspart = kspart + 5;

            url = setupIsoImages(kspart, ksdirectory, location);
            if (!url) {
                logMessage(ERROR, "unable to find %s installation images on hd",
                           getProductName());
                loaderData->method = -1;

                if (loaderData->inferredStage2)
                    loaderData->invalidRepoParam = 1;
            } else {
                free(kspartition);
                free(ksdirectory);
                return url;
            }
        }
    } else {
        kspartition = NULL;
        ksdirectory = NULL;
    }

    /* if we're here its either because this is interactive, or the */
    /* hd kickstart directive was faulty and we have to prompt for  */
    /* location of harddrive image                                  */

    partition_list = NULL;
    while (!done) {
        /* if we're doing another pass free this up first */
        if (partition_list)
            freePartitionsList(partition_list);

        partition_list = getPartitionsList(NULL);
        numPartitions = lenPartitionsList(partition_list);

        /* no partitions found, try to load a device driver disk for storage */
        if (!numPartitions) {
            rc = newtWinChoice(_("Hard Drives"), _("Yes"), _("Back"),
                               _("You don't seem to have any hard drives on "
                                 "your system! Would you like to configure "
                                 "additional devices?"));
            if (rc == 2) {
                loaderData->stage2Data = NULL;
                return NULL;
            }

            rc = loadDriverFromMedia(DEVICE_DISK, loaderData, 0, 0);
            continue;
        }

        /* now find out which partition has the stage2 image */
        checked_asprintf(&buf, _("What partition and directory on that "
                                 "partition holds the installation image "
                                 "for %s?  If you don't see the disk drive "
                                 "you're using listed here, press F2 to "
                                 "configure additional devices."),
                         getProductName());

        text = newtTextboxReflowed(-1, -1, buf, 62, 5, 5, 0);
        free(buf);

        listbox = newtListbox(-1, -1, numPartitions > 5 ? 5 : numPartitions,
                              NEWT_FLAG_RETURNEXIT | 
                              (numPartitions > 5 ? NEWT_FLAG_SCROLL : 0));

        for (i = 0; i < numPartitions; i++)
            newtListboxAppendEntry(listbox,partition_list[i],partition_list[i]);

        /* if we had ks data around use it to prime entry, then get rid of it*/
        if (kspartition) {
            newtListboxSetCurrentByKey(listbox, kspartition);
            free(kspartition);
            kspartition = NULL;
        }

        label = newtLabel(-1, -1, _("Directory holding image:"));

        dirEntry = newtEntry(28, 11, dir, 28, (const char **) &tmpDir,
                             NEWT_ENTRY_SCROLL);

        /* if we had ks data around use it to prime entry, then get rid of it*/
        if (ksdirectory) {
            newtEntrySet(dirEntry, ksdirectory, 1);
            free(ksdirectory);
            ksdirectory = NULL;
        }

        entryGrid = newtGridHStacked(NEWT_GRID_COMPONENT, label,
                                     NEWT_GRID_COMPONENT, dirEntry,
                                     NEWT_GRID_EMPTY);

        buttons = newtButtonBar(_("OK"), &okay, _("Back"), &back, NULL);

        grid = newtCreateGrid(1, 4);
        newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, text,
                         0, 0, 0, 1, 0, 0);
        newtGridSetField(grid, 0, 1, NEWT_GRID_COMPONENT, listbox,
                         0, 0, 0, 1, 0, 0);
        newtGridSetField(grid, 0, 2, NEWT_GRID_SUBGRID, entryGrid,
                         0, 0, 0, 1, 0, 0);
        newtGridSetField(grid, 0, 3, NEWT_GRID_SUBGRID, buttons,
                         0, 0, 0, 0, 0, NEWT_GRID_FLAG_GROWX);

        newtGridWrappedWindow(grid, _("Select Partition"));

        form = newtForm(NULL, NULL, 0);
        newtFormAddHotKey(form, NEWT_KEY_F2);
        newtFormAddHotKey(form, NEWT_KEY_F12);

        newtGridAddComponentsToForm(grid, form, 1);
        newtGridFree(grid, 1);

        newtFormRun(form, &es);

        selpart = newtListboxGetCurrent(listbox);

        free(dir);
        if (tmpDir && *tmpDir) {
            /* Protect from form free. */
            dir = strdup(tmpDir);
        } else  {
            dir = strdup("");
        }

        newtFormDestroy(form);
        newtPopWindow();

        if (es.reason == NEWT_EXIT_COMPONENT && es.u.co == back) {
            loaderData->stage2Data = NULL;
            return NULL;
        } else if (es.reason == NEWT_EXIT_HOTKEY && es.u.key == NEWT_KEY_F2) {
            rc = loadDriverFromMedia(DEVICE_DISK, loaderData, 0, 0);
            continue;
        }

        logMessage(INFO, "partition %s selected", selpart);

        /* If the user-provided URL points at a repo instead of a stage2
         * image, fix that up now.
         */
        substr = strstr(dir, ".img");
        if (!substr || (substr && *(substr+4) != '\0')) {
            checked_asprintf(&dir, "%s/images/install.img", dir);
        }

        loaderData->invalidRepoParam = 1;

        url = setupIsoImages(selpart, dir, location);
        if (!url) {
            newtWinMessage(_("Error"), _("OK"), 
                           _("Device %s does not appear to contain "
                             "an installation image."), selpart, getProductName());
            continue;
        }

        done = 1; 
    }

    free(dir);

    return url;
}
// =======================================================
int CSavingWindow::create(const char *szDevice, const char *szImageFile, const char *szFilesystem, QWORD qwPartSize, COptions options)
{
  BEGIN;

  char szTemp[1024];
  char szTemp2[1024];
  
  SNPRINTF(szTemp, i18n("save partition to image file"));
  newtCenteredWindow(78, 20, szTemp);
  
  SNPRINTF(szTemp, i18n("Partition to save:...........%s"), szDevice);
  m_labelPartition = newtLabel(1, 0, szTemp);
  
  SNPRINTF(szTemp, i18n("Size of the Partition:.......%s = %llu bytes"), formatSize(qwPartSize, szTemp2), qwPartSize);
  m_labelPartitionSize = newtLabel(1, 1, szTemp);
  
  SNPRINTF(szTemp, i18n("Image file to create.........%s"), szImageFile);
  m_labelImageFile = newtLabel(1, 2, szTemp);
  m_labelImageFileSize = newtLabel(1, 3, "");
  
  m_labelFreeSpace = newtLabel(1, 4, "");

  SNPRINTF(szTemp, i18n("Detected file system:........%s"), szFilesystem);
  m_labelFS = newtLabel(1, 5, szTemp);
  
  switch (options.dwCompression)
    {
    case COMPRESS_NONE:
      SNPRINTF(szTemp, i18n("Compression level:...........None"));
      break;
    case COMPRESS_GZIP:
      SNPRINTF(szTemp, i18n("Compression level:...........gzip"));
      break;
    case COMPRESS_BZIP2:
      SNPRINTF(szTemp, i18n("Compression level:...........bzip2"));
      break;
    case COMPRESS_LZO:
      SNPRINTF(szTemp, i18n("Compression level:...........lzo"));
      break;
    }
  m_labelCompression = newtLabel(1, 6, szTemp);

  // stats
  m_labelStatsTime = newtLabel(1, 9, "");
  m_labelStatsTimeRemaining = newtLabel(1, 10, "");
  m_labelStatsSpeed = newtLabel(1, 11, "");
  m_labelStatsSpace = newtLabel(1, 12, "");

  m_progressSaving = newtScale(1, 18, 70, 100);
  m_labelPercent = newtLabel(72, 18, "");
  
  m_formMain = newtForm(NULL, NULL, 0);
  newtFormAddComponents(m_formMain, m_labelPartition, m_labelPartitionSize, m_labelImageFile, m_labelImageFileSize, m_labelFreeSpace, m_labelFS, m_labelCompression, NULL);
  newtFormAddComponents(m_formMain, m_labelStatsTime, m_labelStatsTimeRemaining, m_labelStatsSpeed, m_labelStatsSpace, NULL);
  newtFormAddComponents(m_formMain, m_progressSaving, m_labelPercent, NULL);

  newtRefresh();
  newtDrawForm(m_formMain);
  
  RETURN_int(0);	
}
Example #26
0
int urlMainSetupPanel(struct iurlinfo * ui, urlprotocol protocol,
                      char * doSecondarySetup) {
    newtComponent form, okay, cancel, siteEntry, dirEntry;
    newtComponent answer, text;
    newtComponent cb = NULL;
    char * site, * dir;
    char * reflowedText = NULL;
    int width, height;
    newtGrid entryGrid, buttons, grid;
    char * chptr;
    char * buf = NULL;

    if (ui->address) {
        site = ui->address;
        dir = ui->prefix;
    } else {
        site = "";
        dir = "";
    }

    if (ui->login || ui->password || ui->proxy || ui->proxyPort)
        *doSecondarySetup = '*';
    else
        *doSecondarySetup = ' ';

    buttons = newtButtonBar(_("OK"), &okay, _("Back"), &cancel, NULL);
    
    switch (protocol) {
    case URL_METHOD_FTP:
        buf = sdupprintf(_(netServerPrompt), _("FTP"), getProductName());
        reflowedText = newtReflowText(buf, 47, 5, 5, &width, &height);
        free(buf);
        break;
    case URL_METHOD_HTTP:
        buf = sdupprintf(_(netServerPrompt), _("Web"), getProductName());
        reflowedText = newtReflowText(buf, 47, 5, 5, &width, &height);
        free(buf);
        break;

#ifdef ROCKS
    case URL_METHOD_HTTPS:
        buf = sdupprintf(_(netServerPrompt), "Secure Web", getProductName());
        reflowedText = newtReflowText(buf, 47, 5, 5, &width, &height);
        free(buf);
        break;
#endif /* ROCKS */
    }
    text = newtTextbox(-1, -1, width, height, NEWT_TEXTBOX_WRAP);
    newtTextboxSetText(text, reflowedText);
    free(reflowedText);

    siteEntry = newtEntry(22, 8, site, 24, (const char **) &site, 
                          NEWT_ENTRY_SCROLL);
    dirEntry = newtEntry(22, 9, dir, 24, (const char **) &dir, 
                         NEWT_ENTRY_SCROLL);

    entryGrid = newtCreateGrid(2, 2);
    newtGridSetField(entryGrid, 0, 0, NEWT_GRID_COMPONENT,
                     newtLabel(-1, -1, (protocol == URL_METHOD_FTP) ?
                                        _("FTP site name:") :
                                        _("Web site name:")),
                     0, 0, 1, 0, NEWT_ANCHOR_LEFT, 0);
    newtGridSetField(entryGrid, 0, 1, NEWT_GRID_COMPONENT,
                     newtLabel(-1, -1, 
                               sdupprintf(_("%s directory:"), 
                                          getProductName())),
                     0, 0, 1, 0, NEWT_ANCHOR_LEFT, 0);
    newtGridSetField(entryGrid, 1, 0, NEWT_GRID_COMPONENT, siteEntry,
                     0, 0, 0, 0, 0, 0);
    newtGridSetField(entryGrid, 1, 1, NEWT_GRID_COMPONENT, dirEntry,
                     0, 0, 0, 0, 0, 0);

    grid = newtCreateGrid(1, 4);
    newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, text,
                     0, 0, 0, 1, 0, 0);
    newtGridSetField(grid, 0, 1, NEWT_GRID_SUBGRID, entryGrid,
                     0, 0, 0, 1, 0, 0);

    if (protocol == URL_METHOD_FTP) {
        cb = newtCheckbox(3, 11, _("Use non-anonymous ftp"),
                          *doSecondarySetup, NULL, doSecondarySetup);
        newtGridSetField(grid, 0, 2, NEWT_GRID_COMPONENT, cb,
                         0, 0, 0, 1, NEWT_ANCHOR_LEFT, 0);
    }
        
    newtGridSetField(grid, 0, 3, NEWT_GRID_SUBGRID, buttons,
                     0, 0, 0, 0, 0, NEWT_GRID_FLAG_GROWX);

    newtGridWrappedWindow(grid, (protocol == URL_METHOD_FTP) ? _("FTP Setup") :
                          _("HTTP Setup"));

    form = newtForm(NULL, NULL, 0);
    newtGridAddComponentsToForm(grid, form, 1);    

    do {
        answer = newtRunForm(form);
        if (answer != cancel) {
            if (!strlen(site)) {
                newtWinMessage(_("Error"), _("OK"),
                               _("You must enter a server name."));
                continue;
            }
            if (!strlen(dir)) {
                newtWinMessage(_("Error"), _("OK"),
                               _("You must enter a directory."));
                continue;
            }

            if (!addrToIp(site)) {
                newtWinMessage(_("Unknown Host"), _("OK"),
                        _("%s is not a valid hostname."), site);
                continue;
            }
        }

        break;
    } while (1);
    
    if (answer == cancel) {
        newtFormDestroy(form);
        newtPopWindow();
        
        return LOADER_BACK;
    }

    if (ui->address) free(ui->address);
    ui->address = strdup(site);

    if (ui->prefix) free(ui->prefix);

    /* add a slash at the start of the dir if it is missing */
    if (*dir != '/') {
        if (asprintf(&(ui->prefix), "/%s", dir) == -1)
            ui->prefix = strdup(dir);
    } else {
        ui->prefix = strdup(dir);
    }

    /* Get rid of trailing /'s */
    chptr = ui->prefix + strlen(ui->prefix) - 1;
    while (chptr > ui->prefix && *chptr == '/') chptr--;
    chptr++;
    *chptr = '\0';

    if (*doSecondarySetup != '*') {
        if (ui->login)
            free(ui->login);
        if (ui->password)
            free(ui->password);
        if (ui->proxy)
            free(ui->proxy);
        if (ui->proxyPort)
            free(ui->proxyPort);
        ui->login = ui->password = ui->proxy = ui->proxyPort = NULL;
    }

    ui->protocol = protocol;

    newtFormDestroy(form);
    newtPopWindow();

    return 0;
}
/**
 * Pop up a list containing the filenames in @p source_file and the severity if they have changed since the
 * last backup. There can be no more than @p ARBITRARY_MAXIMUM files in @p source_file.
 * @param source_file The file containing a list of changed files.
 */
	void popup_changelist_from_file(char *source_file) {
		char *reason = NULL;
		newtComponent myForm;
		newtComponent bClose;
		newtComponent bSelect;
		newtComponent b_res;
		newtComponent fileListbox;
		newtComponent headerMsg;

		/*@ ???? ************************************************************ */
		void *curr_choice;
		void *keylist[ARBITRARY_MAXIMUM];

		/*@ int ************************************************************* */
		int i = 0;
		int currline = 0;
		int finished = FALSE;
		long lng = 0;

		/*@ buffers ********************************************************* */
		char *tmp;
		char *differ_sz;

		struct s_filelist *filelist;
		assert_string_is_neither_NULL_nor_zerolength(source_file);
		if (g_text_mode) {
			log_msg(2, "Text mode. Therefore, no popup list.");
			return;
		}
		log_msg(2, "Examining file %s", source_file);

		lng = count_lines_in_file(source_file);
		if (lng < 1) {
			log_msg(2, "No lines in file. Therefore, no popup list.");
			return;
		} else if (lng >= ARBITRARY_MAXIMUM) {
			log_msg(2, "Too many files differ for me to list.");
			return;
		}

		filelist = (struct s_filelist *) malloc(sizeof(struct s_filelist));
		fileListbox =
			newtListbox(2, 2, 12, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
		newtListboxClear(fileListbox);

		if (load_filelist_into_array(filelist, source_file)) {
			log_msg(2, "Can't open %s; therefore, cannot popup list",
					source_file);
			return;
		}
		log_msg(2, "%d files loaded into filelist array",
				filelist->entries);
		for (i = 0; i < filelist->entries; i++) {
			keylist[i] = (void *) i;
			newtListboxAppendEntry(fileListbox,
								   filelist_entry_to_string(&
															(filelist->
															 el[i])),
								   keylist[i]);
		}
		asprintf(&differ_sz,
				 _("  %d files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list."),
				 i);
		newtPushHelpLine(differ_sz);
		paranoid_free(differ_sz);

		bClose = newtCompactButton(10, 15, _(" Close  "));
		bSelect = newtCompactButton(30, 15, _(" Select "));
		asprintf(&tmp, "%-10s               %-20s", _("Priority"),
				 _("Filename"));
		headerMsg = newtLabel(2, 1, tmp);
		paranoid_free(tmp);

		newtOpenWindow(5, 4, 70, 16, _("Non-matching files"));
		myForm = newtForm(NULL, NULL, 0);
		newtFormAddComponents(myForm, headerMsg, fileListbox, bClose,
							  bSelect, NULL);
		while (!finished) {
			b_res = newtRunForm(myForm);
			if (b_res == bClose) {
				finished = TRUE;
			} else {
				curr_choice = newtListboxGetCurrent(fileListbox);
				for (i = 0;
					 i < filelist->entries && keylist[i] != curr_choice;
					 i++);
				if (i == filelist->entries && filelist->entries > 0) {
					log_to_screen(_("I don't know what that button does!"));
				} else {
					currline = i;
					if (filelist->entries > 0) {
						severity_of_difference(filelist->el[currline].
											   filename, reason);
						asprintf(&tmp, "%s --- %s",
								 filelist->el[currline].filename, reason);
						popup_and_OK(tmp);
						paranoid_free(tmp);
						paranoid_free(reason);
					}
				}
			}
		}
		newtFormDestroy(myForm);
		newtPopWindow();
		newtPopHelpLine();
	}
Example #28
0
static newtGrid
show_names(X509_NAME *name)
{
	char value[1024];
	const char *element;
	char *label;
	int i, nameCount, nid;
	X509_NAME_ENTRY *entry;
	newtGrid grid;

	nameCount = X509_NAME_entry_count(name);

	grid = newtCreateGrid(2, nameCount+1);

	for (i=0; i<nameCount; i++) {
		entry = X509_NAME_get_entry(name, i);
		if (!entry) {
			logMessage(ERROR, "Could not find a certificate name");
			return NULL;
		}
		nid = OBJ_obj2nid(entry->object);
		element = OBJ_nid2sn(nid);
		switch (*element) {
			case 'C':
				if (!strcmp(element, "CN"))
					label = _("Name");
				else
					label = _("Country");
				break;
			case 'S':
				label =_("State");
				break;
			case 'L':
				label = _("Locality");
				break;
			case 'e':
			case 'E':
				label = _("Contact");
				break;
			case 'O':
				if (!strcmp(element, "OU"))
					label = _("Org Unit");
				else
					label = _("Org");
				break;
			default:
				label = (char*) element;
		}
		snprintf(value, sizeof(value), "%*s",
			entry->value->length,
			entry->value->data);

		newtGridSetField(grid, 0, i+1, NEWT_GRID_COMPONENT,
			newtLabel(-1,-1, _(label)), 0, 0, 0, 0,
			NEWT_ANCHOR_LEFT, 0);

		newtGridSetField(grid, 1, i+1, NEWT_GRID_COMPONENT,
			newtLabel(-1,-1, _(value)), 2, 0, 0, 0,
			NEWT_ANCHOR_LEFT, NEWT_FLAG_WRAP);
	}
	return grid;
}
Example #29
0
int urlSecondarySetupPanel(struct iurlinfo * ui, urlprotocol protocol) {
    newtComponent form, okay, cancel, answer, text, accountEntry = NULL;
    newtComponent passwordEntry = NULL, proxyEntry = NULL;
    newtComponent proxyPortEntry = NULL;
    char * account, * password, * proxy, * proxyPort;
    newtGrid buttons, entryGrid, grid;
    char * reflowedText = NULL;
    int width, height;

    if (protocol == URL_METHOD_FTP) {
        reflowedText = newtReflowText(
        _("If you are using non anonymous ftp, enter the account name and "
          "password you wish to use below."),
        47, 5, 5, &width, &height);
    } else {
        reflowedText = newtReflowText(
        _("If you are using a HTTP proxy server "
          "enter the name of the HTTP proxy server to use."),
        47, 5, 5, &width, &height);
    }
    text = newtTextbox(-1, -1, width, height, NEWT_TEXTBOX_WRAP);
    newtTextboxSetText(text, reflowedText);
    free(reflowedText);

    if (protocol == URL_METHOD_FTP) {
        accountEntry = newtEntry(-1, -1, NULL, 24, (const char **) &account, 
                                 NEWT_FLAG_SCROLL);
        passwordEntry = newtEntry(-1, -1, NULL, 24, (const char **) &password, 
                                  NEWT_FLAG_SCROLL | NEWT_FLAG_PASSWORD);
    }
    proxyEntry = newtEntry(-1, -1, ui->proxy, 24, (const char **) &proxy, 
                           NEWT_ENTRY_SCROLL);
    proxyPortEntry = newtEntry(-1, -1, ui->proxyPort, 6, 
                               (const char **) &proxyPort, NEWT_FLAG_SCROLL);

    entryGrid = newtCreateGrid(2, 4);
    if (protocol == URL_METHOD_FTP) {
        newtGridSetField(entryGrid, 0, 0, NEWT_GRID_COMPONENT,
                     newtLabel(-1, -1, _("Account name:")),
                     0, 0, 2, 0, NEWT_ANCHOR_LEFT, 0);
        newtGridSetField(entryGrid, 0, 1, NEWT_GRID_COMPONENT,
                     newtLabel(-1, -1, _("Password:"******"OK"), &okay, _("Back"), &cancel, NULL);

    grid = newtCreateGrid(1, 3);
    newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, text, 0, 0, 0, 0, 0, 0);
    newtGridSetField(grid, 0, 1, NEWT_GRID_SUBGRID, entryGrid, 
                     0, 1, 0, 0, 0, 0);
    newtGridSetField(grid, 0, 2, NEWT_GRID_SUBGRID, buttons, 
                     0, 1, 0, 0, 0, NEWT_GRID_FLAG_GROWX);

    if (protocol == URL_METHOD_FTP) {
        newtGridWrappedWindow(grid, _("Further FTP Setup"));
    } else {
        if (protocol == URL_METHOD_HTTP)
            newtGridWrappedWindow(grid, _("Further HTTP Setup"));
    }

    form = newtForm(NULL, NULL, 0);
    newtGridAddComponentsToForm(grid, form, 1);
    newtGridFree(grid, 1);

    answer = newtRunForm(form);
    if (answer == cancel) {
        newtFormDestroy(form);
        newtPopWindow();
        
        return LOADER_BACK;
    }
 
    if (protocol == URL_METHOD_FTP) {
        if (ui->login) free(ui->login);
        if (strlen(account))
            ui->login = strdup(account);
        else
            ui->login = NULL;
        
        if (ui->password) free(ui->password);
        if (strlen(password))
            ui->password = strdup(password);
        else
            ui->password = NULL;
    }
    
    newtFormDestroy(form);
    newtPopWindow();

    return 0;
}
/**
 * Open a progress form with title @p title.
 * @param title The title to use for the progress form (will be put in the title bar on Newt).
 * @param b1 The first line of the blurb; generally static.
 * @param b2 The second line of the blurb; generally static.
 * @param b3 The third line of the blurb; generally dynamic (it is passed
 * to update_evalcall_form() every time).
 * @param max_val The maximum amount of progress (number of filesets, etc.)
 */
	void
	 open_progress_form(char *title, char *b1, char *b2, char *b3,
						long max_val) {

		/*@ buffers ********************************************************* */
		char *b1c;
		char *blurb1;
		char *blurb2;
		char *blurb3;

		/*@ initialize ****************************************************** */
		g_mysterious_dot_counter = 0;

		assert(title != NULL);
		assert(b1 != NULL);
		assert(b2 != NULL);
		assert(b3 != NULL);

		asprintf(&blurb1, b1);
		asprintf(&blurb2, b2);
		asprintf(&blurb3, b3);
		asprintf(&b1c, b1);
		/* BERLIOS: center_string is now broken replace it ! */
		//center_string(b1c, 80);
		if (max_val <= 0) {
			max_val = 1;
		}

		g_start_time = get_time();
		g_maximum_progress = max_val;
		g_current_progress = 0;
		// BERLIOS: We need to unallocate them
		asprintf(&g_blurb_str_1, blurb1);
		asprintf(&g_blurb_str_2, blurb3);
		asprintf(&g_blurb_str_3, blurb2);
		if (g_text_mode) {
			log_msg(0, blurb1);
			log_msg(0, blurb2);
			log_msg(0, blurb3);
		} else {
			g_blurb1 = newtLabel(2, 1, blurb1);
			g_blurb2 = newtLabel(2, 2, blurb3);
			g_blurb3 = newtLabel(2, 4, blurb2);
			//      newtOpenWindow (10, 4, 60, 11, title);
			newtCenteredWindow(60, 11, title);
			g_scale = newtScale(3, 6, 54, g_maximum_progress);
			g_progressForm = newtForm(NULL, NULL, 0);
			g_percentline = newtLabel(10, 9, "This is the percentline");
			g_timeline = newtLabel(10, 8, "This is the timeline");
			newtFormAddComponents(g_progressForm, g_percentline,
								  g_timeline, g_scale, g_blurb1, g_blurb3,
								  g_blurb2, NULL);
			newtPushHelpLine(b1c);
			newtRefresh();
		}
		update_progress_form_full(blurb1, blurb2, blurb3);
		paranoid_free(b1c);
		paranoid_free(blurb1);
		paranoid_free(blurb2);
		paranoid_free(blurb3);
	}