text:
#include "vice.h"

#include <stdio.h>
#include <windows.h>
#include <tchar.h>

#ifdef HAVE_SHLOBJ_H
#include <shlobj.h>
#endif

#include "attach.h"
#include "autostart.h"
#include "iecdrive.h"
#include "imagecontents.h"
#include "intl.h"
#include "lib.h"
#include "opencbmlib.h"
#include "printer.h"
#include "res.h"
#include "resources.h"
#include "system.h"
#include "translate.h"
#include "ui.h"
#include "uiapi.h"
#include "uilib.h"
#include "uiperipheral.h"
#include "winlong.h"
#include "winmain.h"

/* -------------------------------------------------------------------------- */
/*                             Disk Peripherals (8-11)                        */
/* -------------------------------------------------------------------------- */

static void enable_controls_for_disk_device_type(HWND hwnd, int type)
{
    EnableWindow(GetDlgItem(hwnd, IDC_DISKIMAGE), type == IDC_SELECTDISK);
    EnableWindow(GetDlgItem(hwnd, IDC_BROWSEDISK), type == IDC_SELECTDISK);
    EnableWindow(GetDlgItem(hwnd, IDC_AUTOSTART), type == IDC_SELECTDISK);
    EnableWindow(GetDlgItem(hwnd, IDC_TOGGLE_ATTACH_READONLY), type == IDC_SELECTDISK);
    EnableWindow(GetDlgItem(hwnd, IDC_DIR), type == IDC_SELECTDIR);
    EnableWindow(GetDlgItem(hwnd, IDC_BROWSEDIR), type == IDC_SELECTDIR);
    EnableWindow(GetDlgItem(hwnd, IDC_TOGGLE_READP00), type == IDC_SELECTDIR);
    EnableWindow(GetDlgItem(hwnd, IDC_TOGGLE_WRITEP00), type == IDC_SELECTDIR);
    EnableWindow(GetDlgItem(hwnd, IDC_TOGGLE_HIDENONP00), type == IDC_SELECTDIR);
}

static void enable_controls(HWND hwnd)
{
    int drive_true_emulation, virtual_device_traps;
    BOOL haveIECDevice;

    resources_get_int("DriveTrueEmulation", &drive_true_emulation);
    resources_get_int("VirtualDevices", &virtual_device_traps);
    haveIECDevice = IsDlgButtonChecked(hwnd, IDC_TOGGLE_USEIECDEVICE) == BST_CHECKED;

    if ((drive_true_emulation || !virtual_device_traps) && !haveIECDevice) {
        EnableWindow(GetDlgItem(hwnd, IDC_SELECTDISK), FALSE);
        EnableWindow(GetDlgItem(hwnd, IDC_SELECTDIR), FALSE);
        EnableWindow(GetDlgItem(hwnd, IDC_SELECTNONE), FALSE);
#ifdef HAVE_OPENCBM
        if (opencbmlib_is_available()) {
            EnableWindow(GetDlgItem(hwnd, IDC_SELECTREAL), FALSE);
        }
#endif
    } else {
        EnableWindow(GetDlgItem(hwnd, IDC_SELECTDISK), TRUE);
        EnableWindow(GetDlgItem(hwnd, IDC_SELECTDIR), TRUE);
        EnableWindow(GetDlgItem(hwnd, IDC_SELECTNONE), TRUE);
#ifdef HAVE_OPENCBM
        if (opencbmlib_is_available()) {
            EnableWindow(GetDlgItem(hwnd, IDC_SELECTREAL), TRUE);
        }
#endif
    }
}

static uilib_localize_dialog_param diskdevice_opencbm_dialog[] = {
    { IDC_TOGGLE_USEIECDEVICE, IDS_TOGGLE_USEIECDEVICE, 0 },
    { IDC_SELECTDISK, IDS_SELECTDISK, 0 },
    { IDC_SELECTDIR, IDS_SELECTDIR, 0 },
#ifdef HAVE_OPENCBM
    { IDC_SELECTREAL, IDS_SELECTREAL, 0 },
#endif
    { IDC_SELECTNONE, IDS_SELECTNONE, 0 },
    { IDC_BROWSEDISK, IDS_BROWSE, 0 },
    { IDC_AUTOSTART, IDS_AUTOSTART, 0 },
    { IDC_TOGGLE_ATTACH_READONLY, IDS_TOGGLE_ATTACH_READONLY, 0 },
    { IDC_BROWSEDIR, IDS_BROWSEDIR, 0 },
    { IDC_DISKDEVICE_OPTIONS, IDS_MP_OPTIONS, 0 },
    { IDC_TOGGLE_READP00, IDS_TOGGLE_READP00, 0 },
    { IDC_TOGGLE_WRITEP00, IDS_TOGGLE_WRITEP00, 0 },
    { IDC_TOGGLE_HIDENONP00, IDS_TOGGLE_HIDENONP00, 0 },
    { 0, 0, 0 }
};

static uilib_localize_dialog_param diskdevice_normal_dialog[] = {
    { IDC_TOGGLE_USEIECDEVICE, IDS_TOGGLE_USEIECDEVICE, 0 },
    { IDC_SELECTDISK, IDS_SELECTDISK, 0 },
    { IDC_SELECTDIR, IDS_SELECTDIR, 0 },
    { IDC_SELECTNONE, IDS_SELECTNONE, 0 },
    { IDC_BROWSEDISK, IDS_BROWSE, 0 },
    { IDC_AUTOSTART, IDS_AUTOSTART, 0 },
    { IDC_TOGGLE_ATTACH_READONLY, IDS_TOGGLE_ATTACH_READONLY, 0 },
    { IDC_BROWSEDIR, IDS_BROWSEDIR, 0 },
    { IDC_DISKDEVICE_OPTIONS, IDS_MP_OPTIONS, 0 },
    { IDC_TOGGLE_READP00, IDS_TOGGLE_READP00, 0 },
    { IDC_TOGGLE_WRITEP00, IDS_TOGGLE_WRITEP00, 0 },
    { IDC_TOGGLE_HIDENONP00, IDS_TOGGLE_HIDENONP00, 0 },
    { 0, 0, 0 }
};

static uilib_dialog_group diskdevice_read_only[] = {
    { IDC_TOGGLE_ATTACH_READONLY, 1 },
    { 0, 0 }
};

static uilib_dialog_group diskdevice_left_group[] = {
    { IDC_SELECTDISK, 1 },
    { IDC_SELECTDIR, 1 },
    { 0, 0 }
};

static uilib_dialog_group diskdevice_middle_group[] = {
    { IDC_DISKIMAGE, 0 },
    { IDC_BROWSEDISK, 0 },
    { IDC_DIR, 0 },
    { IDC_BROWSEDIR, 0 },
    { 0, 0 }
};

static uilib_dialog_group diskdevice_right_group[] = {
    { IDC_TOGGLE_READP00, 1 },
    { IDC_TOGGLE_WRITEP00, 1 },
    { IDC_TOGGLE_HIDENONP00, 1 },
    { 0, 0 }
};

static uilib_dialog_group diskdevice_filling_group[] = {
    { IDC_TOGGLE_USEIECDEVICE, 0 },
    { IDC_DISKIMAGE, 0 },
    { IDC_DIR, 0 },
    { IDC_DISKDEVICE_OPTIONS, 0 },
    { IDC_SELECTNONE, 0 },
    { 0, 0 }
};

static void init_dialog(HWND hwnd, unsigned int num)
{
    const char *disk_image, *dir;
    TCHAR *st_disk_image, *st_dir;
    int devtype, n;
    int xpos, xpos1, xpos2, xpos3;
    int distance1, distance2;
    RECT rect;
    uilib_localize_dialog_param *diskdevice_dialog =
#ifdef HAVE_OPENCBM
      (opencbmlib_is_available()) ? diskdevice_opencbm_dialog :
#endif
      diskdevice_normal_dialog;

    if (num >= 8 && num <= 11) {
        /* translate all dialog items */
        uilib_localize_dialog(hwnd, diskdevice_dialog);

        /* adjust the size of the elements in the diskdevice_left_group */
        uilib_adjust_group_width(hwnd, diskdevice_left_group);

        /* adjust the size of the 'read-only' element */
        uilib_adjust_group_width(hwnd, diskdevice_read_only);

        /* get the min x of the read only element */
        uilib_get_element_min_x(hwnd, IDC_TOGGLE_ATTACH_READONLY, &xpos3);

        /* get the min x of the autostart element */
        uilib_get_element_min_x(hwnd, IDC_AUTOSTART, &xpos2);

        /* get the max x of the first browse element */
        uilib_get_element_max_x(hwnd, IDC_BROWSEDISK, &xpos1);

        /* calculate the distance between the browse button and the autostart button */
        distance1 = xpos2 - xpos1;

        /* get the max x of the autostart element */
        uilib_get_element_max_x(hwnd, IDC_AUTOSTART, &xpos2);

        /* calculate the distance between the browse button and the read only element */
        distance2 = xpos3 - xpos2;

        /* get the max x of the disk_device_left_group items */
        uilib_get_group_max_x(hwnd, diskdevice_left_group, &xpos);

        /* move the filename elements and browse buttons to the right position */
        uilib_move_group(hwnd, diskdevice_middle_group, xpos + 10);

        /* get the max x of the first browse element */
        uilib_get_element_max_x(hwnd, IDC_BROWSEDISK, &xpos);

        /* move the autostart element to the right position */
        uilib_move_element(hwnd, IDC_AUTOSTART, xpos + distance1);

        /* resize the autostart element */
        uilib_adjust_element_width(hwnd, IDC_AUTOSTART);

        /* get the max x of the autostart element */
        uilib_get_element_max_x(hwnd, IDC_AUTOSTART, &xpos);

        /* move the read only element to the right position */
        uilib_move_element(hwnd, IDC_TOGGLE_ATTACH_READONLY, xpos + distance2);

#ifdef HAVE_OPENCBM
        if (opencbmlib_is_available()) {
            /* adjust the size of the real iec element */
            uilib_adjust_element_width(hwnd, IDC_SELECTREAL);

            /* get the max x of the real iec element */
            uilib_get_element_max_x(hwnd, IDC_SELECTREAL, &xpos1);
        } else {
            xpos1 = 0;
        }
#else
        xpos1 = 0;
#endif

        /* get the max x of the second browse button */
        uilib_get_element_max_x(hwnd, IDC_BROWSEDIR, &xpos2);

        if (xpos2 > xpos1) {
            xpos = xpos2 + 20;
        } else {
            xpos = xpos1 + 20;
        }

        /* move the diskdevice_right_group to the right position */
        uilib_move_group(hwnd, diskdevice_right_group, xpos);

        /* move the p00 group element to the right position */
        uilib_move_element(hwnd, IDC_DISKDEVICE_OPTIONS, xpos - 5);

        /* adjust the diskdevice_right_group elements size */
        uilib_adjust_group_width(hwnd, diskdevice_right_group);

        /* adjust the p00 group element size */
        uilib_adjust_element_width(hwnd, IDC_DISKDEVICE_OPTIONS);

        /* get the width of the disk_device_right_group items */
        uilib_get_group_width(hwnd, diskdevice_right_group, &xpos1);

        /* get the width of the p00 group element */
        uilib_get_element_width(hwnd, IDC_DISKDEVICE_OPTIONS, &xpos2);

        if (xpos2 + 5 > xpos1) {
            xpos = xpos2 + 15;
        } else {
            xpos = xpos1 + 10;
        }

        /* set the width of the p00 group element */
        uilib_set_element_width(hwnd, IDC_DISKDEVICE_OPTIONS, xpos);

        /* adjust the none element size */
        uilib_adjust_element_width(hwnd, IDC_SELECTNONE);

        /* adjust the size of the use iec device element */
        uilib_adjust_element_width(hwnd, IDC_TOGGLE_USEIECDEVICE);

        /* get the max x of the window filling elements */
        uilib_get_group_max_x(hwnd, diskdevice_filling_group, &xpos);

        /* set the width of the dialog to 'surround' all the elements */
        GetWindowRect(hwnd, &rect);
        MoveWindow(hwnd, rect.left, rect.top, xpos + 10, rect.bottom - rect.top, TRUE);

        disk_image = file_system_get_disk_name(num);
        st_disk_image = system_mbstowcs_alloc(disk_image);
        SetDlgItemText(hwnd, IDC_DISKIMAGE, st_disk_image != NULL ? st_disk_image : TEXT(""));
        system_mbstowcs_free(st_disk_image);

        resources_get_string_sprintf("FSDevice%dDir", &dir, num);
        st_dir = system_mbstowcs_alloc(dir);
        SetDlgItemText(hwnd, IDC_DIR, st_dir != NULL ? st_dir : TEXT(""));
        system_mbstowcs_free(st_dir);

        resources_get_int_sprintf("FSDevice%dConvertP00", &n, num);
        CheckDlgButton(hwnd, IDC_TOGGLE_READP00, n ? BST_CHECKED : BST_UNCHECKED);

        resources_get_int_sprintf("FSDevice%dSaveP00", &n, num);
        CheckDlgButton(hwnd, IDC_TOGGLE_WRITEP00, n ? BST_CHECKED : BST_UNCHECKED);

        resources_get_int_sprintf("FSDevice%dHideCBMFiles", &n, num);
        CheckDlgButton(hwnd, IDC_TOGGLE_HIDENONP00, n ? BST_CHECKED : BST_UNCHECKED);

        resources_get_int_sprintf("AttachDevice%dReadonly", &n, num);
        CheckDlgButton(hwnd, IDC_TOGGLE_ATTACH_READONLY, n ? BST_CHECKED : BST_UNCHECKED);

        resources_get_int_sprintf("FileSystemDevice%d", &devtype, num);
        switch (devtype) {
            case ATTACH_DEVICE_FS:
                if (disk_image != NULL) {
                    n = IDC_SELECTDISK;
                } else {
                    n = IDC_SELECTDIR;
                }
                break;
#ifdef HAVE_OPENCBM
            case ATTACH_DEVICE_REAL:
                n = IDC_SELECTREAL;
                break;
#endif
            default:
                n = IDC_SELECTNONE;
        }

#ifdef HAVE_OPENCBM
        if (opencbmlib_is_available()) {
            CheckRadioButton(hwnd, IDC_SELECTDISK, IDC_SELECTREAL, n);
        } else {
            CheckRadioButton(hwnd, IDC_SELECTDISK, IDC_SELECTDIR, n);
        }
#else
        CheckRadioButton(hwnd, IDC_SELECTDISK, IDC_SELECTDIR, n);
#endif
        enable_controls_for_disk_device_type(hwnd, n);

        if (iec_available_busses() & IEC_BUS_IEC) {
            resources_get_int_sprintf("IECDevice%d", &n, num);
            CheckDlgButton(hwnd, IDC_TOGGLE_USEIECDEVICE, n ? BST_CHECKED : BST_UNCHECKED);
        } else {
            CheckDlgButton(hwnd, IDC_TOGGLE_USEIECDEVICE, BST_UNCHECKED);
            ShowWindow(GetDlgItem(hwnd, IDC_TOGGLE_USEIECDEVICE), FALSE);
        }

        enable_controls(hwnd);
    }
}

static BOOL store_dialog_results(HWND hwnd, unsigned int num)
{
    char s[MAX_PATH];
    TCHAR st[MAX_PATH];
    int devtype = ATTACH_DEVICE_NONE;

    if (IsDlgButtonChecked(hwnd, IDC_SELECTDISK) == BST_CHECKED) {
        GetDlgItemText(hwnd, IDC_DISKIMAGE, st, MAX_PATH);
        system_wcstombs(s, st, MAX_PATH);
        if (file_system_attach_disk(num, s) < 0 ) {
            ui_error(translate_text(IDS_CANNOT_ATTACH_FILE));
            return 0;
        }
    } else {
        if ((IsDlgButtonChecked(hwnd, IDC_SELECTDIR) == BST_CHECKED) && file_system_get_disk_name(num)) {
            file_system_detach_disk(num);
        }
    }

    if (iec_available_busses() & IEC_BUS_IEC) {
        resources_set_int_sprintf("IECDevice%d", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_USEIECDEVICE) == BST_CHECKED), num);
    }

    if (IsDlgButtonChecked(hwnd, IDC_SELECTDISK) == BST_CHECKED || IsDlgButtonChecked(hwnd, IDC_SELECTDIR) == BST_CHECKED) {
        devtype = ATTACH_DEVICE_FS;
    }
#ifdef HAVE_OPENCBM
    if (opencbmlib_is_available()) {
        if (IsDlgButtonChecked(hwnd, IDC_SELECTREAL) == BST_CHECKED) {
            devtype = ATTACH_DEVICE_REAL;
        }
    }
#endif
    resources_set_int_sprintf("FileSystemDevice%d", devtype, num);

    resources_set_int_sprintf("FSDevice%dConvertP00", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_READP00) == BST_CHECKED), num);
    resources_set_int_sprintf("FSDevice%dSaveP00", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_WRITEP00) == BST_CHECKED), num);
    resources_set_int_sprintf("FSDevice%dHideCBMFiles", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_HIDENONP00) == BST_CHECKED), num);
    resources_set_int_sprintf("AttachDevice%dReadonly", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_ATTACH_READONLY) == BST_CHECKED), num);

    GetDlgItemText(hwnd, IDC_DIR, st, MAX_PATH);
    system_wcstombs(s, st, MAX_PATH);
    resources_set_string_sprintf("FSDevice%dDir", s, num);

    return 1;
}

static void browse_diskimage(HWND hwnd)
{
    TCHAR *st_name;

    st_name = uilib_select_file(hwnd, translate_text(IDS_ATTACH_DISK_IMAGE), UILIB_FILTER_ALL | UILIB_FILTER_DISK | UILIB_FILTER_ZIP, UILIB_SELECTOR_TYPE_FILE_LOAD, UILIB_SELECTOR_STYLE_DISK);

    if (st_name != NULL) {
        SetDlgItemText(hwnd, IDC_DISKIMAGE, st_name);
        lib_free(st_name);
    }
}

static void autostart_diskimage(HWND hwnd)
{
    TCHAR *st_name;

    st_name = uilib_select_file(hwnd, translate_text(IDS_AUTOSTART_DISK_IMAGE), UILIB_FILTER_ALL | UILIB_FILTER_DISK | UILIB_FILTER_ZIP, UILIB_SELECTOR_TYPE_FILE_LOAD, UILIB_SELECTOR_STYLE_DISK);

    if (st_name != NULL) {
        char *name;

        SetDlgItemText(hwnd, IDC_DISKIMAGE, st_name);
        name = system_wcstombs_alloc(st_name);
        if (autostart_autodetect(name, "*", 0, AUTOSTART_MODE_RUN) < 0) {
            ui_error(translate_text(IDS_CANNOT_AUTOSTART_FILE));
        }
        system_wcstombs_free(name);
        lib_free(st_name);
    }
}

static void browse_dir(HWND hwnd)
{
    BROWSEINFO bi;
    TCHAR st[MAX_PATH];
    LPITEMIDLIST idlist;

    bi.hwndOwner = hwnd;
    bi.pidlRoot = NULL;
    bi.pszDisplayName = st;
    bi.lpszTitle = translate_text(IDS_SELECT_FS_DIRECTORY);
    bi.ulFlags = 0;
    bi.lpfn = NULL;
    bi.lParam = 0;
    bi.iImage = 0;
    if ((idlist = SHBrowseForFolder(&bi)) != NULL) {
        SHGetPathFromIDList(idlist, st);
        LocalFree(idlist);
        /*
        If a root directory is selected, \ is appended
        and has to be deleted.
        */
        if (st[_tcslen(st) - 1] == '\\') {
            st[_tcslen(st) - 1] = '\0';
        }
        SetDlgItemText(hwnd, IDC_DIR, st);
    }
}

static BOOL CALLBACK dialog_proc(unsigned int num, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
    switch (msg) {
        case WM_INITDIALOG:
            init_dialog(hwnd, num);
            return TRUE;
        case WM_NOTIFY:
            {
                NMHDR *nmhdr = (NMHDR *)(lparam);

                switch (nmhdr->code) {
                    case PSN_APPLY:
                        SetWindowLongPtr(hwnd, DWLP_MSGRESULT, store_dialog_results(hwnd, num) ? PSNRET_NOERROR : PSNRET_INVALID);
                        return TRUE;
                }
                break;
            }
        case WM_COMMAND:
            switch (LOWORD(wparam)) {
                case IDC_SELECTDIR:
                case IDC_SELECTDISK:
                case IDC_SELECTREAL:
                case IDC_SELECTNONE:
                    enable_controls_for_disk_device_type(hwnd, LOWORD(wparam));
                    break;
  	          case IDC_TOGGLE_USEIECDEVICE:
                    enable_controls(hwnd);
                    break;
                case IDC_BROWSEDISK:
                    browse_diskimage(hwnd);
                    break;
                case IDC_AUTOSTART:
                    autostart_diskimage(hwnd);
                    break;
                case IDC_BROWSEDIR:
                    browse_dir(hwnd);
                    break;
            }
            return TRUE;
    }
    return FALSE;
}

#define _CALLBACK(num)                                                                      \
static INT_PTR CALLBACK callback_##num(HWND dialog, UINT msg, WPARAM wparam, LPARAM lparam) \
{                                                                                \
    return dialog_proc(num, dialog, msg, wparam, lparam);                                   \
}

_CALLBACK(8)
_CALLBACK(9)
_CALLBACK(10)
_CALLBACK(11)

/* -------------------------------------------------------------------------- */
/*                           Printers (Userport, 4-5)                         */
/* -------------------------------------------------------------------------- */

static int have_printer_userport = -1;

static char *printertextdevice[3] = { NULL, NULL, NULL };

static const int ui_printer_opencbm[] = {
    IDS_NONE,
    IDS_FILE_SYSTEM,
#ifdef HAVE_OPENCBM
    IDS_REAL_IEC_DEVICE,
#endif
    0
};

static const int ui_printer_normal[] = {
    IDS_NONE,
    IDS_FILE_SYSTEM,
    0
};

static const TCHAR *ui_printer_driver[] = {
    TEXT("ASCII"),
    TEXT("MPS803"),
    TEXT("NL10"),
    TEXT("RAW"),
    NULL
};

static const char *ui_printer_driver_ascii[] = {
    "ascii",
    "mps803",
    "nl10",
    "raw",
    NULL
};

static const char *ui_printer_output[] = {
    "Text",
    "Graphics",
    NULL
};

static const char *ui_printer_output_ascii[] = {
    "text",
    "graphics",
    NULL
};

static const TCHAR *ui_printer_text_device[] = {
    TEXT("1"),
    TEXT("2"),
    TEXT("3"),
    NULL
};

static void enable_printer_controls(unsigned int num, HWND hwnd)
{
    int res_value, is_enabled;
    int drive_true_emulation, virtual_device_traps;
    BOOL haveIECDevice;

    resources_get_int("DriveTrueEmulation", &drive_true_emulation);
    resources_get_int("VirtualDevices", &virtual_device_traps);
    haveIECDevice = IsDlgButtonChecked(hwnd, IDC_PRINTER_USEIECDEVICE) == BST_CHECKED;

    if (num > 0 && ((drive_true_emulation || !virtual_device_traps) && !haveIECDevice)) {
        EnableWindow(GetDlgItem(hwnd, IDC_PRINTER_TYPE), FALSE);
        SendMessage(GetDlgItem(hwnd, IDC_PRINTER_TYPE), CB_SETCURSEL, 0, 0);
    } else {
        EnableWindow(GetDlgItem(hwnd, IDC_PRINTER_TYPE), TRUE);
    }

    res_value = (int)SendMessage(GetDlgItem(hwnd, IDC_PRINTER_TYPE), CB_GETCURSEL, 0, 0);

    is_enabled = res_value == PRINTER_DEVICE_FS;

    EnableWindow(GetDlgItem(hwnd, IDC_PRINTER_FORMFEED), is_enabled);
    EnableWindow(GetDlgItem(hwnd, IDC_PRINTER_DRIVER), is_enabled);
    EnableWindow(GetDlgItem(hwnd, IDC_PRINTER_OUTPUT), is_enabled);
    EnableWindow(GetDlgItem(hwnd, IDC_PRINTER_TEXTOUT), is_enabled);
    EnableWindow(GetDlgItem(hwnd, IDC_PRINTER_OUTPUT_FILE1_NAME), is_enabled);
    EnableWindow(GetDlgItem(hwnd, IDC_PRINTER_OUTPUT_FILE2_NAME), is_enabled);
    EnableWindow(GetDlgItem(hwnd, IDC_PRINTER_OUTPUT_FILE3_NAME), is_enabled);
}

static uilib_localize_dialog_param printer_dialog_trans[] = {
    { IDC_PRINTER_EMULATION, IDS_PRINTER_EMULATION, 0 },
    { IDC_PRINTER_FORMFEED, IDS_PRINTER_FORMFEED, 0 },
    { IDC_FILESYSTEM_PRINTER, IDS_FILESYSTEM_PRINTER, 0 },
    { IDC_PRINTER_DRVR, IDS_PRINTER_DRVR, 0 },
    { IDC_OUTPUT, IDS_OUTPUT, 0 },
    { IDC_OUTPUT_TO_FILE, IDS_OUTPUT_TO_FILE, 0 },
    { IDC_OUTPUT_FILE1_NAME, IDS_OUTPUT_FILE1_NAME, 0 },
    { IDC_OUTPUT_FILE2_NAME, IDS_OUTPUT_FILE2_NAME, 0 },
    { IDC_OUTPUT_FILE3_NAME, IDS_OUTPUT_FILE3_NAME, 0 },
    { 0, 0, 0 }
};

static uilib_localize_dialog_param printer_iec_dialog_trans[] = {
    { IDC_PRINTER_USEIECDEVICE, IDS_TOGGLE_USEIECDEVICE, 0 },
    { 0, 0, 0 }
};

static uilib_dialog_group printer_left_group[] = {
    { IDC_PRINTER_EMULATION, 0 },
    { IDC_PRINTER_DRVR, 0 },
    { IDC_OUTPUT, 0 },
    { IDC_OUTPUT_TO_FILE, 0 },
    { IDC_OUTPUT_FILE1_NAME, 0 },
    { IDC_OUTPUT_FILE2_NAME, 0 },
    { IDC_OUTPUT_FILE3_NAME, 0 },
    { 0, 0 }
};

static uilib_dialog_group printer_top_right_group[] = {
    { IDC_PRINTER_TYPE, 0 },
    { IDC_PRINTER_DRIVER, 0 },
    { IDC_PRINTER_OUTPUT, 0 },
    { IDC_PRINTER_TEXTOUT, 0 },
    { 0, 0 }
};

static uilib_dialog_group printer_bottom_right_group[] = {
    { IDC_PRINTER_OUTPUT_FILE1_NAME, 0 },
    { IDC_PRINTER_OUTPUT_FILE2_NAME, 0 },
    { IDC_PRINTER_OUTPUT_FILE3_NAME, 0 },
    { 0, 0 }
};

static uilib_dialog_group formfeed_group[] = {
    { IDC_PRINTER_FORMFEED, 1 },
    { 0, 0 }
};

static void init_printer_dialog(unsigned int num, HWND hwnd)
{
    HWND printer_hwnd;
    int i, res_value, res_value_loop;
    char  printer_name[30];
    const char *res_string;
    int current = 0;
    int xmax;
    int xpos;
    int size;
    const int *ui_printer =
#ifdef HAVE_OPENCBM
      (opencbmlib_is_available()) ? ui_printer_opencbm :
#endif
      ui_printer_normal;

    /* translate all dialog items */
    uilib_localize_dialog(hwnd, printer_dialog_trans);

    if (num != 0) {
        /* translate the iec dialog item(s) */
        uilib_localize_dialog(hwnd, printer_iec_dialog_trans);
    }

    /* adjust the size of the elements in the left group */
    uilib_adjust_group_width(hwnd, printer_left_group);

    /* get the max x of the bottom right group */
    uilib_get_group_max_x(hwnd, printer_bottom_right_group, &xmax);

    /* get the size of one of the elements of the bottom right group */
    uilib_get_element_size(hwnd, IDC_PRINTER_OUTPUT_FILE3_NAME, &size);

    /* get the max x of the left group */
    uilib_get_group_max_x(hwnd, printer_left_group, &xpos);

    /* move the top right group to the correct position */
    uilib_move_group(hwnd, printer_top_right_group, xpos + 10);

    /* move the bottom right group to the correct position */
    uilib_move_group(hwnd, printer_bottom_right_group, xpos + 10);

    /* get the max x of the bottom right group */
    uilib_get_group_max_x(hwnd, printer_bottom_right_group, &xpos);

    /* set the size of the bottom right group */
    uilib_set_group_width(hwnd, printer_bottom_right_group, size + xpos - xmax);

    /* get the max x of the printer emulation drop down element */
    uilib_get_element_max_x(hwnd, IDC_PRINTER_TYPE, &xpos);

    /* adjust the size of the elements in formfeed group */
    uilib_adjust_group_width(hwnd, formfeed_group);

    /* move the send formfeed button */
    uilib_move_element(hwnd, IDC_PRINTER_FORMFEED, xpos + 10);

    if (num == 0) {
        sprintf(printer_name, "PrinterUserport");
    } else {
        sprintf(printer_name, "Printer%d", num);
    }

    resources_get_int(printer_name, &res_value);
    printer_hwnd = GetDlgItem(hwnd, IDC_PRINTER_TYPE);
    for (res_value_loop = 0; ui_printer[res_value_loop]; res_value_loop++) {
        SendMessage(printer_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(ui_printer[res_value_loop]));
    }
    SendMessage(printer_hwnd, CB_SETCURSEL, (WPARAM)res_value, 0);

    resources_get_string_sprintf("%sDriver", &res_string, printer_name);
    printer_hwnd = GetDlgItem(hwnd, IDC_PRINTER_DRIVER);
    for (res_value_loop = 0; ui_printer_driver[res_value_loop]; res_value_loop++) {
        SendMessage(printer_hwnd, CB_ADDSTRING, 0, (LPARAM)ui_printer_driver[res_value_loop]);
        if (!strcmp(ui_printer_driver_ascii[res_value_loop], res_string)) {
            current = res_value_loop;
        }
    }
    SendMessage(printer_hwnd, CB_SETCURSEL, (WPARAM)current, 0);

    resources_get_string_sprintf("%sOutput", &res_string, printer_name);
    printer_hwnd = GetDlgItem(hwnd, IDC_PRINTER_OUTPUT);
    for (res_value_loop = 0; ui_printer_output[res_value_loop]; res_value_loop++) {
        SendMessage(printer_hwnd, CB_ADDSTRING, 0, (LPARAM)ui_printer_output[res_value_loop]);
        if (!strcmp(ui_printer_output_ascii[res_value_loop], res_string)) {
            current = res_value_loop;
        }
    }
    SendMessage(printer_hwnd, CB_SETCURSEL, (WPARAM)current, 0);

    resources_get_int_sprintf("%sTextDevice", &res_value, printer_name);
    printer_hwnd = GetDlgItem(hwnd, IDC_PRINTER_TEXTOUT);
    for (res_value_loop = 0; ui_printer_text_device[res_value_loop]; res_value_loop++) {
        SendMessage(printer_hwnd, CB_ADDSTRING, 0, (LPARAM)ui_printer_text_device[res_value_loop]);
    }
    SendMessage(printer_hwnd, CB_SETCURSEL, (WPARAM)res_value, 0);

    if (num > 0 && (iec_available_busses() & IEC_BUS_IEC)) {
        resources_get_int_sprintf("IECDevice%d", &res_value, num);
        CheckDlgButton(hwnd, IDC_PRINTER_USEIECDEVICE, res_value ? BST_CHECKED : BST_UNCHECKED);
    } else {
        ShowWindow(GetDlgItem(hwnd, IDC_PRINTER_USEIECDEVICE), FALSE);
        CheckDlgButton(hwnd, IDC_PRINTER_USEIECDEVICE, BST_UNCHECKED);
    }

    for (i = 0; i < 3; i++) {
        resources_get_string_sprintf("PrinterTextDevice%d", &res_string, i + 1);
        if (res_string) {
            strncpy(printertextdevice[i], res_string, MAX_PATH);
        }
    }

    enable_printer_controls(num, hwnd);
}

static BOOL store_printer_dialog_results(HWND hwnd, unsigned int num)
{
    char printer_name[30];

    if (num == 0) {
        sprintf(printer_name, "PrinterUserport");
    } else {
        sprintf(printer_name, "Printer%d", num);
    }

    resources_set_int(printer_name, (int)SendMessage(GetDlgItem(hwnd, IDC_PRINTER_TYPE), CB_GETCURSEL, 0, 0));

    resources_set_string_sprintf("%sDriver", ui_printer_driver_ascii[SendMessage(GetDlgItem(hwnd, IDC_PRINTER_DRIVER), CB_GETCURSEL, 0, 0)], printer_name);

    resources_set_string_sprintf("%sOutput", ui_printer_output_ascii[SendMessage(GetDlgItem(hwnd, IDC_PRINTER_OUTPUT), CB_GETCURSEL, 0, 0)], printer_name);

    resources_set_int_sprintf("%sTextDevice", (int)SendMessage(GetDlgItem(hwnd, IDC_PRINTER_TEXTOUT), CB_GETCURSEL, 0, 0), printer_name);

    resources_set_string("PrinterTextDevice1", printertextdevice[0]);
    resources_set_string("PrinterTextDevice2", printertextdevice[1]);
    resources_set_string("PrinterTextDevice3", printertextdevice[2]);

    if (num > 0 && (iec_available_busses() & IEC_BUS_IEC)) {
        resources_set_int_sprintf("IECDevice%d", (IsDlgButtonChecked(hwnd, IDC_PRINTER_USEIECDEVICE) == BST_CHECKED), num);
    }

    return 1;
}

static void printer_set_active(HWND hwnd)
{
    TCHAR *st;

    st = system_mbstowcs_alloc(printertextdevice[0]);
    SetDlgItemText(hwnd, IDC_PRINTER_OUTPUT_FILE1_NAME, st);
    system_mbstowcs_free(st);
    st = system_mbstowcs_alloc(printertextdevice[1]);
    SetDlgItemText(hwnd, IDC_PRINTER_OUTPUT_FILE2_NAME, st);
    system_mbstowcs_free(st);
    st = system_mbstowcs_alloc(printertextdevice[2]);
    SetDlgItemText(hwnd, IDC_PRINTER_OUTPUT_FILE3_NAME, st);
    system_mbstowcs_free(st);
}

static void printer_kill_active(HWND hwnd)
{
    TCHAR st[MAX_PATH];

    GetDlgItemText(hwnd, IDC_PRINTER_OUTPUT_FILE1_NAME, st, MAX_PATH);
    system_wcstombs(printertextdevice[0], st, MAX_PATH);
    GetDlgItemText(hwnd, IDC_PRINTER_OUTPUT_FILE2_NAME, st, MAX_PATH);
    system_wcstombs(printertextdevice[1], st, MAX_PATH);
    GetDlgItemText(hwnd, IDC_PRINTER_OUTPUT_FILE3_NAME, st, MAX_PATH);
    system_wcstombs(printertextdevice[2], st, MAX_PATH);
}

static BOOL CALLBACK printer_dialog_proc(unsigned int num, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
    int command;

    switch (msg) {
        case WM_COMMAND:
            command = LOWORD(wparam);
            switch (command) {
                case IDC_PRINTER_TYPE:
                case IDC_PRINTER_USEIECDEVICE:
                    enable_printer_controls(num, hwnd);
                    break;
                case IDC_PRINTER_FORMFEED:
                    switch (num) {
                        case 4:
                            printer_formfeed(0);
                            break;
                        case 5:
                            printer_formfeed(1);
                            break;
                        case 0:
                            printer_formfeed(2);
                            break;
                    }
                    break;
            }
            return FALSE;
        case WM_NOTIFY:
            {
                NMHDR FAR *nmhdr = (NMHDR FAR *)(lparam);

                switch (nmhdr->code) {
                    case PSN_APPLY:
                        SetWindowLongPtr(hwnd, DWLP_MSGRESULT, store_printer_dialog_results(hwnd, num) ? PSNRET_NOERROR : PSNRET_INVALID);
                        return TRUE;
                    case PSN_SETACTIVE:
                        printer_set_active(hwnd);
                        return TRUE;
                    case PSN_KILLACTIVE:
                        printer_kill_active(hwnd);
                        return TRUE;
                }
                break;
            }
        case WM_CLOSE:
            EndDialog(hwnd, 0);
            return TRUE;
        case WM_INITDIALOG:
            system_init_dialog(hwnd);
            init_printer_dialog(num, hwnd);
            return TRUE;
    }

    return FALSE;
}

#define _CALLBACK_PRINTER(num)                                                              \
static INT_PTR CALLBACK callback_##num(HWND dialog, UINT msg, WPARAM wparam, LPARAM lparam) \
{                                                                                \
    return printer_dialog_proc(num, dialog, msg, wparam, lparam);                           \
}

_CALLBACK_PRINTER(0)
_CALLBACK_PRINTER(4)
_CALLBACK_PRINTER(5)

/* -------------------------------------------------------------------------- */
/*                               Main Dialog                                  */
/* -------------------------------------------------------------------------- */

static void uiperipheral_dialog(HWND hwnd)
{
    PROPSHEETPAGE psp[7];
    PROPSHEETHEADER psh;
    int i, no_of_drives, no_of_printers;

    for (i = 0; i < 3; i++ ) {
        printertextdevice[i] = lib_malloc(MAX_PATH);
        strcpy(printertextdevice[i], "");
    }

    no_of_drives = 4;
    no_of_printers = 2;

    if (have_printer_userport < 0) {
        have_printer_userport = (resources_touch("PrinterUserport")) < 0 ? 0 : 1;
    }
    if (have_printer_userport) {
        no_of_printers++;
    }

    for (i = 0; i < no_of_printers; i++) {
        psp[i].dwSize = sizeof(PROPSHEETPAGE);
        psp[i].dwFlags = PSP_USETITLE /*| PSP_HASHELP*/ ;
        psp[i].hInstance = winmain_instance;
#ifdef _ANONYMOUS_UNION
        psp[i].pszTemplate = MAKEINTRESOURCE(IDD_PRINTER_SETTINGS_DIALOG);
        psp[i].pszIcon = NULL;
#else
        psp[i].DUMMYUNIONNAME.pszTemplate
            = MAKEINTRESOURCE(IDD_PRINTER_SETTINGS_DIALOG);
        psp[i].u2.pszIcon = NULL;
#endif
        psp[i].lParam = 0;
        psp[i].pfnCallback = NULL;
    }

    for (i = 0; i < no_of_drives; i++) {
        psp[no_of_printers + i].dwSize = sizeof(PROPSHEETPAGE);
        psp[no_of_printers + i].dwFlags = PSP_USETITLE /*| PSP_HASHELP*/ ;
        psp[no_of_printers + i].hInstance = winmain_instance;
#ifdef _ANONYMOUS_UNION
#ifdef HAVE_OPENCBM
        if (opencbmlib_is_available()) {
            psp[no_of_printers + i].pszTemplate = MAKEINTRESOURCE(IDD_DISKDEVICE_OPENCBM_DIALOG);
        } else
#endif
        {
            psp[no_of_printers + i].pszTemplate = MAKEINTRESOURCE(IDD_DISKDEVICE_DIALOG);
        }
        psp[no_of_printers + i].pszIcon = NULL;
#else
#ifdef HAVE_OPENCBM
        if (opencbmlib_is_available()) {
            psp[no_of_printers + i].DUMMYUNIONNAME.pszTemplate = MAKEINTRESOURCE(IDD_DISKDEVICE_OPENCBM_DIALOG);
        } else
#endif
        {
            psp[no_of_printers + i].DUMMYUNIONNAME.pszTemplate = MAKEINTRESOURCE(IDD_DISKDEVICE_DIALOG);
        }
        psp[no_of_printers + i].u2.pszIcon = NULL;
#endif
        psp[no_of_printers + i].lParam = 0;
        psp[no_of_printers + i].pfnCallback = NULL;
    }

    if (have_printer_userport) {
        psp[0].pfnDlgProc = callback_0;
        psp[0].pszTitle = translate_text(IDS_PRINTER_USERPORT);
        i = 1;
    } else
        i = 0;

    psp[i + 0].pfnDlgProc = callback_4;
    psp[i + 0].pszTitle = translate_text(IDS_PRINTER_4);
    psp[i + 1].pfnDlgProc = callback_5;
    psp[i + 1].pszTitle = translate_text(IDS_PRINTER_5);
    psp[i + 2].pfnDlgProc = callback_8;
    psp[i + 2].pszTitle = translate_text(IDS_DRIVE_8);
    psp[i + 3].pfnDlgProc = callback_9;
    psp[i + 3].pszTitle = translate_text(IDS_DRIVE_9);
    psp[i + 4].pfnDlgProc = callback_10;
    psp[i + 4].pszTitle = translate_text(IDS_DRIVE_10);
    psp[i + 5].pfnDlgProc = callback_11;
    psp[i + 5].pszTitle = translate_text(IDS_DRIVE_11);

    psh.dwSize = sizeof(PROPSHEETHEADER);
    psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
    psh.hwndParent = hwnd;
    psh.hInstance = winmain_instance;
    psh.pszCaption = translate_text(IDS_PERIPHERAL_SETTINGS);
    psh.nPages = no_of_drives + no_of_printers;
#ifdef _ANONYMOUS_UNION
    psh.pszIcon = NULL;
    psh.nStartPage = i + 2;
    psh.ppsp = psp;
#else
    psh.DUMMYUNIONNAME.pszIcon = NULL;
    psh.u2.nStartPage = i + 2;
    psh.u3.ppsp = psp;
#endif
    psh.pfnCallback = NULL;

    PropertySheet(&psh);

    for (i = 0; i < 3; i++) {
        lib_free(printertextdevice[i]);
    }
}

void uiperipheral_command(HWND hwnd, WPARAM wparam)
{
    switch (wparam & 0xffff) {
        case IDM_DEVICEMANAGER:
            uiperipheral_dialog(hwnd);
            break;
        case IDM_FORMFEED_PRINTERIEC4:
            printer_formfeed(0);
            break;
        case IDM_FORMFEED_PRINTERIEC5:
            printer_formfeed(1);
            break;
    }
}


text:
<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>

    Dashboard

        Some Welcome Text like last login Details....

                    Weekly forecast
                    November 2013 - December 2013

$1486

                                Total earnings

$863

                                Weekly revenue

$622

                                New sources

$65

                                Gross margin

                        <select data-placeholder="Change statistics area" class="chosen-select">
                            <option value="" />
                            <option value="United States" />United States
                            <option value="United Kingdom" />United Kingdom
                            <option value="Afghanistan" />Afghanistan
                            <option value="Aland Islands" />Aland Islands
                            <option value="Albania" />Albania
                            <option value="Algeria" />Algeria
                            <option value="American Samoa" />American Samoa
                            <option value="Andorra" />Andorra
                            <option value="Angola" />Angola
                            <option value="Anguilla" />Anguilla
                            <option value="Antarctica" />Antarctica
                            <option value="Antigua and Barbuda" />Antigua and Barbuda
                            <option value="Argentina" />Argentina
                            <option value="Armenia" />Armenia
                            <option value="Aruba" />Aruba
                            <option value="Australia" />Australia
                            <option value="Austria" />Austria
                            <option value="Azerbaijan" />Azerbaijan
                            <option value="Bahamas" />Bahamas
                            <option value="Bahrain" />Bahrain
                            <option value="Bangladesh" />Bangladesh
                            <option value="Barbados" />Barbados
                            <option value="Belarus" />Belarus
                            <option value="Belgium" />Belgium
                            <option value="Belize" />Belize
                            <option value="Benin" />Benin
                            <option value="Bermuda" />Bermuda
                            <option value="Bhutan" />Bhutan
                        </select>

                            New registrations
                            August - October 2013

183,579,180,311,405,342,579,405,311,311,450,302,370,510

                            521 active accounts

                            Shipped items
                            January - December 2013

183,579,180,311,405,342,579,405,450,311,180,311,450,302,370,210

                            5 pending shipments

                            YoY growth
                            2013 - 2014

183,579,180,311,240,180,311,450,302,370,210,610

                            289 new visits

                            Monthly evolution
                            July - December 2013

183,579,180,311,230,311,405,342,230,302,405,230,405,342,579,405

                            8 overdue orders

redpajama_set_name: RedPajamaGithub


text:
from __future__ import division
import sys

aggregate_results = dict()

if __name__ == '__main__':
    for line in sys.stdin:
        vartype, filt, af, ac, vqslod, mie, none = line.rstrip().split('\t')
        keytuple = (vartype, filt, af, ac, vqslod)
        if keytuple not in aggregate_results:
            aggregate_results[keytuple] = [ 0, 0 ]
        aggregate_results[keytuple][0] += int(mie)
        aggregate_results[keytuple][1] += int(none)

    for key in aggregate_results:
        mie = aggregate_results[key][0]
        none = aggregate_results[key][1]
        print '\t'.join(key + ( str(mie), str(none), str(mie / (mie + none)) ))


text:
package info.globalbus.blueprint.plugin.model;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Set;

class BeanTemplate {
    final Class<?> clazz;
    final Set<Annotation> qualifiers;

    BeanTemplate(Class<?> clazz, Annotation[] qualifiers) {
        this.clazz = clazz;
        this.qualifiers = QualifierHelper.getQualifiers(qualifiers);
    }

    BeanTemplate(Field field) {
        this(field.getType(), field.getAnnotations());
    }

    BeanTemplate(Method method) {
        this(method.getParameterTypes()[0], method.getAnnotations());
    }

}


text:
/* Generated by camel build tools - do NOT edit this file! */
package org.apache.camel.component.vertx.websocket;

import java.util.Map;

import org.apache.camel.CamelContext;
import org.apache.camel.spi.ExtendedPropertyConfigurerGetter;
import org.apache.camel.spi.PropertyConfigurerGetter;
import org.apache.camel.spi.ConfigurerStrategy;
import org.apache.camel.spi.GeneratedPropertyConfigurer;
import org.apache.camel.util.CaseInsensitiveMap;
import org.apache.camel.support.component.PropertyConfigurerSupport;

/**
 * Generated by camel build tools - do NOT edit this file!
 */
@SuppressWarnings("unchecked")
public class VertxWebsocketEndpointConfigurer extends PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter {

    @Override
    public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
        VertxWebsocketEndpoint target = (VertxWebsocketEndpoint) obj;
        switch (ignoreCase ? name.toLowerCase() : name) {
        case "allowedoriginpattern":
        case "allowedOriginPattern": target.getConfiguration().setAllowedOriginPattern(property(camelContext, java.lang.String.class, value)); return true;
        case "bridgeerrorhandler":
        case "bridgeErrorHandler": target.setBridgeErrorHandler(property(camelContext, boolean.class, value)); return true;
        case "clientoptions":
        case "clientOptions": target.getConfiguration().setClientOptions(property(camelContext, io.vertx.core.http.HttpClientOptions.class, value)); return true;
        case "clientsubprotocols":
        case "clientSubProtocols": target.getConfiguration().setClientSubProtocols(property(camelContext, java.lang.String.class, value)); return true;
        case "exceptionhandler":
        case "exceptionHandler": target.setExceptionHandler(property(camelContext, org.apache.camel.spi.ExceptionHandler.class, value)); return true;
        case "exchangepattern":
        case "exchangePattern": target.setExchangePattern(property(camelContext, org.apache.camel.ExchangePattern.class, value)); return true;
        case "lazystartproducer":
        case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
        case "router": target.getConfiguration().setRouter(property(camelContext, io.vertx.ext.web.Router.class, value)); return true;
        case "sendtoall":
        case "sendToAll": target.getConfiguration().setSendToAll(property(camelContext, boolean.class, value)); return true;
        case "serveroptions":
        case "serverOptions": target.getConfiguration().setServerOptions(property(camelContext, io.vertx.core.http.HttpServerOptions.class, value)); return true;
        case "sslcontextparameters":
        case "sslContextParameters": target.getConfiguration().setSslContextParameters(property(camelContext, org.apache.camel.support.jsse.SSLContextParameters.class, value)); return true;
        default: return false;
        }
    }

    @Override
    public Class<?> getOptionType(String name, boolean ignoreCase) {
        switch (ignoreCase ? name.toLowerCase() : name) {
        case "allowedoriginpattern":
        case "allowedOriginPattern": return java.lang.String.class;
        case "bridgeerrorhandler":
        case "bridgeErrorHandler": return boolean.class;
        case "clientoptions":
        case "clientOptions": return io.vertx.core.http.HttpClientOptions.class;
        case "clientsubprotocols":
        case "clientSubProtocols": return java.lang.String.class;
        case "exceptionhandler":
        case "exceptionHandler": return org.apache.camel.spi.ExceptionHandler.class;
        case "exchangepattern":
        case "exchangePattern": return org.apache.camel.ExchangePattern.class;
        case "lazystartproducer":
        case "lazyStartProducer": return boolean.class;
        case "router": return io.vertx.ext.web.Router.class;
        case "sendtoall":
        case "sendToAll": return boolean.class;
        case "serveroptions":
        case "serverOptions": return io.vertx.core.http.HttpServerOptions.class;
        case "sslcontextparameters":
        case "sslContextParameters": return org.apache.camel.support.jsse.SSLContextParameters.class;
        default: return null;
        }
    }

    @Override
    public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
        VertxWebsocketEndpoint target = (VertxWebsocketEndpoint) obj;
        switch (ignoreCase ? name.toLowerCase() : name) {
        case "allowedoriginpattern":
        case "allowedOriginPattern": return target.getConfiguration().getAllowedOriginPattern();
        case "bridgeerrorhandler":
        case "bridgeErrorHandler": return target.isBridgeErrorHandler();
        case "clientoptions":
        case "clientOptions": return target.getConfiguration().getClientOptions();
        case "clientsubprotocols":
        case "clientSubProtocols": return target.getConfiguration().getClientSubProtocols();
        case "exceptionhandler":
        case "exceptionHandler": return target.getExceptionHandler();
        case "exchangepattern":
        case "exchangePattern": return target.getExchangePattern();
        case "lazystartproducer":
        case "lazyStartProducer": return target.isLazyStartProducer();
        case "router": return target.getConfiguration().getRouter();
        case "sendtoall":
        case "sendToAll": return target.getConfiguration().isSendToAll();
        case "serveroptions":
        case "serverOptions": return target.getConfiguration().getServerOptions();
        case "sslcontextparameters":
        case "sslContextParameters": return target.getConfiguration().getSslContextParameters();
        default: return null;
        }
    }
}


text:
package xworker.chart.jfree.dataobject.swt;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Collections;
import java.util.List;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.experimental.chart.swt.ChartComposite;
import org.xmeta.ActionContext;
import org.xmeta.Bindings;
import org.xmeta.Thing;
import org.xmeta.util.UtilMap;

import ognl.OgnlException;
import xworker.app.view.swt.data.DataStore;
import xworker.app.view.swt.data.DataStoreDisposeListener;
import xworker.chart.jfree.JfreeInit;
import xworker.chart.jfree.dataobject.DataObjectChart;
import xworker.chart.jfree.dataobject.DataObjectChartFactory;
import xworker.chart.jfree.dataobject.data.DataObjectReloadableDataset;
import xworker.dataObject.DataObject;
import xworker.swt.design.Designer;
import xworker.swt.util.SwtUtils;

public class SwtDataObjectChart {
	static {
		JfreeInit.init();
	}

	public static Object create(ActionContext actionContext) throws OgnlException, IOException{
		Thing self = (Thing) actionContext.get("self");

		//设置字体,默认字体显示不了中文
		JfreeInit.init();

		//chart
		JFreeChart jfreechart = null;

		int width = self.getInt("width", 0, actionContext);
		if(width <= 0){
		    width = ChartComposite.DEFAULT_WIDTH;
		}

		int height = self.getInt("height", 0, actionContext);
		if(height <= 0){
		    height = ChartComposite.DEFAULT_HEIGHT;
		}

		int minimumDrawW = self.getInt("minimumDrawW", 0, actionContext);
		if(minimumDrawW <= 0){
		    minimumDrawW = ChartComposite.DEFAULT_MINIMUM_DRAW_WIDTH;
		}

		int minimumDrawH = self.getInt("minimumDrawH", 0, actionContext);
		if(minimumDrawH <= 0){
		    minimumDrawH = ChartComposite.DEFAULT_MINIMUM_DRAW_HEIGHT;
		}

		int maximumDrawW = self.getInt("maximumDrawW", 0, actionContext);
		if(maximumDrawW <= 0){
		    maximumDrawW = ChartComposite.DEFAULT_MAXIMUM_DRAW_WIDTH;
		}

		int maximumDrawH = self.getInt("maximumDrawH", 0, actionContext);
		if(maximumDrawH <= 0){
		    maximumDrawH = ChartComposite.DEFAULT_MAXIMUM_DRAW_HEIGHT;
		}

		boolean usingBuffer = self.getBoolean("usingBuffer", false, actionContext);
		boolean properties = self.getBoolean("properties", false, actionContext);
		boolean save = self.getBoolean("save", false, actionContext);
		boolean print = self.getBoolean("print", false, actionContext);
		boolean zoom = self.getBoolean("zoom", false, actionContext);
		boolean tooltips = self.getBoolean("tooltips", false, actionContext);

		Composite parent = (Composite) actionContext.get("parent");
		Control chartComposite = null;
		if(SwtUtils.isRWT()) {
			chartComposite = new Canvas(parent, SWT.NONE | SWT.DOUBLE_BUFFERED);

			//销毁jfreechart生成的图片
			chartComposite.addListener(SWT.Dispose, new Listener() {
				@Override
				public void handleEvent(Event event) {
					Canvas canvas = (Canvas) event.widget;
					Image image = canvas.getBackgroundImage();
					if(image != null && !image.isDisposed()) {
						image.dispose();
					}
				}

			});
			chartComposite.addListener(SWT.Resize, new Listener() {
				@Override
				public void handleEvent(Event event) {
					Canvas canvas = (Canvas) event.widget;
					updateCanvasJFreechart(canvas);
				}
			});
		}else {
			chartComposite = new ChartComposite(parent, SWT.NONE, jfreechart,width,height,
			        minimumDrawW,minimumDrawH,maximumDrawW,maximumDrawH,
			        usingBuffer,properties,save,print,zoom,tooltips);
		}

		Designer.attach(chartComposite, self.getMetadata().getPath(), actionContext);
		//创建子事物
		try{
		    Bindings bindings = actionContext.push(null);
		    bindings.put("parent", chartComposite);
		    bindings.put("__jfreeChartComposite__", chartComposite);
		    for(Thing child : self.getChilds()){
		    	if("DataStores".equals(child.getThingName())){
		    		//应为会在getDataStore中创建DataStore,所以过滤DataStore节点
		    		continue;
		    	}

		        child.doAction("create", actionContext);
		    }

		    Thing dataStore = (Thing) self.doAction("getDataStore", actionContext);
		    attachToDataStore(dataStore, chartComposite, actionContext);
		}finally{
		    actionContext.pop();
		}

		//放入变量范围
		actionContext.getScope(0).put(self.getString("name"), chartComposite);
		return chartComposite;
	}

	public static void attachDataStore(ActionContext actionContext) throws IOException {
		Thing dataStore = actionContext.getObject("dataStore");
		Control control = actionContext.getObject("control");

		attachToDataStore(dataStore, control, actionContext);
	}

	@SuppressWarnings("unchecked")
	public static void attachToDataStore(Thing dataStore, Control chartComposite, ActionContext actionContext) throws IOException {
		if(dataStore == null) {
			return;
		}

		Thing self = Designer.getThing(chartComposite);

		List<DataObject> datas = Collections.emptyList();
	    if(dataStore != null && dataStore.get("records") != null){
	    	datas = (List<DataObject>) dataStore.get("records");
	    }

	    actionContext.peek().put("self", self);
	    DataObjectChart chart = DataObjectChartFactory.create(actionContext, datas);
	    if(chart != null){
	    	if(SwtUtils.isRWT()) {
	    		//ChartUtilities.wr
	    		chartComposite.setData("__jfreeChartComposite__chart__", chart);
	    	}else {
	    		((ChartComposite) chartComposite).setChart(chart.chart);
	    	}

	    	if(dataStore != null && chart.dataset instanceof DataObjectReloadableDataset){
	    		dataStore.put("dataObjectDataset", chart.dataset);
	    	}
	    }

	    if(dataStore != null){
	    	dataStore.put("__jfreeChartComposite__", chartComposite);
	    	dataStore.doAction("addListener", actionContext, UtilMap.toMap("listener", self));

	    	chartComposite.setData(DataStore.STORE, dataStore);
	    	chartComposite.setData(DataStore.LISTENER, self);
	    	DataStoreDisposeListener.attach(chartComposite);

	    }
	}

	public static void updateCanvasJFreechart(final Canvas canvas) {
		canvas.getDisplay().asyncExec(new Runnable() {
			@SuppressWarnings("unchecked")
			public void run() {
				try {
					DataObjectChart chart = (DataObjectChart) canvas.getData("__jfreeChartComposite__chart__");
					DataObjectReloadableDataset dataSet = null;
					if(chart.dataset instanceof DataObjectReloadableDataset) {
						dataSet = (DataObjectReloadableDataset) chart.dataset;
						List<DataObject> datas = (List<DataObject>) canvas.getData("__datas__");
						dataSet.reload(datas);
					}

					int width = canvas.getClientArea().width;
					int height = canvas.getClientArea().height;
					ByteArrayOutputStream bout = new ByteArrayOutputStream();
					ChartUtilities.writeChartAsPNG(bout, chart.chart, width, height);

					Image image = canvas.getBackgroundImage();
					if(image != null && !image.isDisposed()) {
						image.dispose();
					}

					ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
					image = new Image(canvas.getDisplay(), bin);
					canvas.setBackgroundImage(image);
					bin.close();
					bout.close();
				}catch(Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	@SuppressWarnings("unchecked")
	public static void onLoaded(ActionContext actionContext){
		Thing dataStore = (Thing) actionContext.get("store");
		final DataObjectReloadableDataset dataset = (DataObjectReloadableDataset) dataStore.get("dataObjectDataset");
		final List<DataObject> datas = (List<DataObject>) dataStore.get("records");

		if(SwtUtils.isRWT()) {
			final Canvas canvas = (Canvas) dataStore.get("__jfreeChartComposite__");
			canvas.setData("__datas__", datas);
			updateCanvasJFreechart(canvas);
		}else {

			ChartComposite chartComposite = (ChartComposite) dataStore.get("__jfreeChartComposite__");
			if(chartComposite == null || chartComposite.isDisposed()) {
				return;
			}

			chartComposite.getDisplay().asyncExec(new Runnable(){
				public void run(){
					try{
						dataset.reload(datas);
					}catch(Exception e){
						e.printStackTrace();
					}
				}
			});
		}

	}
}


text:
@interface ZLChatTableViewCell : UITableViewCell
//@property(nonatomic,assign) id<ZLChatTableViewCellDelegate> delegate;

@property (nonatomic, strong) MessageModel *messageModel;

@property(nonatomic,strong) UILabel *timestampLabel;
@property (nonatomic, strong) UIImageView *headImageView;       //头像
@property (nonatomic, strong) UILabel *nameLabel;               //姓名(暂时不支持显示)
@property (nonatomic, strong) ZLChatBaseBubbleView *bubbleView;   //内容区域

//sender
@property (nonatomic, strong) UIActivityIndicatorView *activtiy;
@property (nonatomic, strong) UIView *activityView;
@property (nonatomic, strong) UIButton *retryButton;

- (id)initWithMessageModel:(MessageModel *)model reuseIdentifier:(NSString *)reuseIdentifier;
//- (void)setupSubviewsForMessageModel:(MessageModel *)model;
- (void)configureCellWithMessage:(MessageModel*)message displaysTimestamp:(BOOL)displayts;

+ (CGFloat)cellHeightForRowAtIndexPath:(NSIndexPath *)indexPath withObject:(MessageModel *)model;
+ (NSString *)cellIdentifierForMessageModel:(MessageModel *)model;

@end


text:
<?php
/**
 * This file is part of the Zimbra API in PHP library.
 *
 * © Nguyen Van Nguyen <nguyennv1981@gmail.com>
 *
 * For the full copyfba and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Zimbra\Mail\Struct;

use Zimbra\Common\TypedSequence;
use Zimbra\Enum\FreeBusyStatus;
use Zimbra\Enum\Transparency;
use Zimbra\Enum\InviteStatus;
use Zimbra\Enum\InviteClass;
use Zimbra\Enum\InviteChange;
use Zimbra\Struct\Base;

/**
 * InviteComponentCommon struct class
 *
 * @package    Zimbra
 * @subpackage Mail
 * @category   Struct
 * @author     Nguyen Van Nguyen - nguyennv1981@gmail.com
 * @copyright  Copyfba © 2013 by Nguyen Van Nguyen.
 */
class InviteComponentCommon extends Base
{
    /**
     * Comma-separated list of changed data in an updated invite.
     * Possible values are "subject", "location", "time" (start time, end time, or duration), and "recurrence".
     * @var TypedSequence
     */
    private $_changes;

    /**
     * Constructor method for InviteComponentCommon
     *
     * @param string $method The method
     * @param int    $compNum Component number of the invite
     * @param bool   $rsvp RSVP flag. Set if response requested, unset if no response requested
     * @param int    $priority Priority (0 - 9; default = 0)
     * @param string $name The name
     * @param string $loc Location
     * @param int    $percentComplete Percent complete for VTODO (0 - 100; default = 0)
     * @param string $completed VTODO COMPLETED DATE-TIME in format yyyyMMddThhmmssZ
     * @param bool   $noBlob Set if invite has no blob data, i.e. all data is in db metadata
     * @param FreeBusyStatus $fba The "actual" free-busy status of this invite (ie what the client should display).
     * @param FreeBusyStatus $fb FreeBusy setting F|B|T|U
     * @param Transparency $transp Transparency - O|T. i.e. Opaque or Transparent
     * @param bool   $isOrg Am I the organizer? [default 0 (false)]
     * @param string $x_uid The x_uid
     * @param string $uid UID to use when creating appointment. Optional: client can request the UID to use
     * @param int    $seq Sequence number (default = 0)
     * @param int    $d Date - used for zdsync
     * @param string $calItemId Mail item ID of appointment
     * @param string $apptId Appointment ID (deprecated)
     * @param string $ciFolder Folder of appointment
     * @param InviteStatus $status Status - TENT|CONF|CANC|NEED|COMP|INPR|WAITING|DEFERRED
     * @param InviteClass $class Class = PUB|PRI|CON. i.e. PUBlic (default), PRIvate, CONfidential
     * @param string $url The url
     * @param bool   $ex Set if this is invite is an exception
     * @param string $ridZ Recurrence-id string in UTC timezone
     * @param bool   $allDay Set if is an all day appointment
     * @param bool   $draft Set if invite has changes that haven't been sent to attendees; for organizer only
     * @param bool   $neverSent Set if attendees were never notified of this invite; for organizer only
     * @param array  $change
     */
    public function __construct(
        $method,
        $compNum,
        $rsvp,
        $priority = null,
        $name = null,
        $loc = null,
        $percentComplete = null,
        $completed = null,
        $noBlob = null,
        FreeBusyStatus $fba = null,
        FreeBusyStatus $fb = null,
        Transparency $transp = null,
        $isOrg = null,
        $x_uid = null,
        $uid = null,
        $seq = null,
        $d = null,
        $calItemId = null,
        $apptId = null,
        $ciFolder = null,
        InviteStatus $status = null,
        InviteClass $class = null,
        $url = null,
        $ex = null,
        $ridZ = null,
        $allDay = null,
        $draft = null,
        $neverSent = null,
        array $changes = array()
    )
    {
        parent::__construct();
        $this->property('method', trim($method));
        $this->property('compNum', (int) $compNum);
        $this->property('rsvp', (bool) $rsvp);
        if(null !== $priority)
        {
            $this->property('priority', ((int) $priority > 0 or (int) $priority < 10) ? (int) $priority : 0);
        }
        if(null !== $name)
        {
            $this->property('name', trim($name));
        }
        if(null !== $loc)
        {
            $this->property('loc', trim($loc));
        }
        if(null !== $percentComplete)
        {
            $this->property('percentComplete', ((int) $percentComplete > 0 or (int) $percentComplete <= 100) ? (int) $percentComplete : 0);
        }
        if(null !== $completed)
        {
            $this->property('completed', trim($completed));
        }
        if(null !== $noBlob)
        {
            $this->property('noBlob', (bool) $noBlob);
        }
        if($fba instanceof FreeBusyStatus)
        {
            $this->property('fba', $fba);
        }
        if($fb instanceof FreeBusyStatus)
        {
            $this->property('fb', $fb);
        }
        if($transp instanceof Transparency)
        {
            $this->property('transp', $transp);
        }
        if(null !== $isOrg)
        {
            $this->property('isOrg', (bool) $isOrg);
        }
        if(null !== $x_uid)
        {
            $this->property('x_uid', trim($x_uid));
        }
        if(null !== $uid)
        {
            $this->property('uid', trim($uid));
        }
        if(null !== $seq)
        {
            $this->property('seq', (int) $seq);
        }
        if(null !== $d)
        {
            $this->property('d', (int) $d);
        }
        if(null !== $calItemId)
        {
            $this->property('calItemId', trim($calItemId));
        }
        if(null !== $apptId)
        {
            $this->property('apptId', trim($apptId));
        }
        if(null !== $ciFolder)
        {
            $this->property('ciFolder', trim($ciFolder));
        }
        if($status instanceof InviteStatus)
        {
            $this->property('status', $status);
        }
        if($class instanceof InviteClass)
        {
            $this->property('class', $class);
        }
        if(null !== $url)
        {
            $this->property('url', trim($url));
        }
        if(null !== $ex)
        {
            $this->property('ex', (bool) $ex);
        }
        if(null !== $ridZ)
        {
            $this->property('ridZ', trim($ridZ));
        }
        if(null !== $allDay)
        {
            $this->property('allDay', (bool) $allDay);
        }
        if(null !== $draft)
        {
            $this->property('draft', (bool) $draft);
        }
        if(null !== $neverSent)
        {
            $this->property('neverSent', (bool) $neverSent);
        }

        $this->_changes = new TypedSequence('Zimbra\Enum\InviteChange', $changes);

        $this->on('before', function(Base $sender)
        {
            $changes = $sender->changes();
            if(!empty($changes))
            {
                $sender->property('changes', $sender->changes());
            }
        });
    }

    /**
     * Gets or sets method
     *
     * @param  string $method
     * @return string|self
     */
    public function method($method = null)
    {
        if(null === $method)
        {
            return $this->property('method');
        }
        return $this->property('method', trim($method));
    }

    /**
     * Gets or sets compNum
     *
     * @param  int $compNum
     * @return int|self
     */
    public function compNum($compNum = null)
    {
        if(null === $compNum)
        {
            return $this->property('compNum');
        }
        return $this->property('compNum', (int) $compNum);
    }

    /**
     * Gets or sets rsvp
     *
     * @param  bool $rsvp
     * @return bool|self
     */
    public function rsvp($rsvp = null)
    {
        if(null === $rsvp)
        {
            return $this->property('rsvp');
        }
        return $this->property('rsvp', (bool) $rsvp);
    }

    /**
     * Gets or sets priority
     *
     * @param  int $priority
     * @return int|self
     */
    public function priority($priority = null)
    {
        if(null === $priority)
        {
            return $this->property('priority');
        }
        return $this->property('priority', ((int) $priority > 0 or (int) $priority < 10) ? (int) $priority : 0);
    }

    /**
     * Gets or sets name
     *
     * @param  string $name
     * @return string|self
     */
    public function name($name = null)
    {
        if(null === $name)
        {
            return $this->property('name');
        }
        return $this->property('name', trim($name));
    }

    /**
     * Gets or sets loc
     *
     * @param  string $loc
     * @return string|self
     */
    public function loc($loc = null)
    {
        if(null === $loc)
        {
            return $this->property('loc');
        }
        return $this->property('loc', trim($loc));
    }

    /**
     * Gets or sets seq
     *
     * @param  int $seq
     * @return int|self
     */
    public function percentComplete($percentComplete = null)
    {
        if(null === $percentComplete)
        {
            return $this->property('percentComplete');
        }
        return $this->property('percentComplete', ((int) $percentComplete > 0 or (int) $percentComplete <= 100) ? (int) $percentComplete : 0);
    }

    /**
     * Gets or sets completed
     * VTODO COMPLETED DATE-TIME in format yyyyMMddThhmmssZ
     *
     * @param  string $completed
     * @return string|self
     */
    public function completed($completed = null)
    {
        if(null === $completed)
        {
            return $this->property('completed');
        }
        return $this->property('completed', trim($completed));
    }

    /**
     * Gets or sets noBlob
     *
     * @param  boolean $noBlob
     * @return boolean|self
     */
    public function noBlob($noBlob = null)
    {
        if(null === $noBlob)
        {
            return $this->property('noBlob');
        }
        return $this->property('noBlob', (bool) $noBlob);
    }

    /**
     * Gets or sets "actual" free-busy status
     * Valid values - F|B|T|U. i.e. Free, Busy (default), busy-Tentative, OutOfOffice (busy-unavailable)
     *
     * @param  FreeBusyStatus $fb
     * @return FreeBusyStatus|self
     */
    public function fba(FreeBusyStatus $fba = null)
    {
        if(null === $fba)
        {
            return $this->property('fba');
        }
        return $this->property('fba', $fba);
    }

    /**
     * Gets or sets FreeBusy setting
     * Valid values: F|B|T|U
     * i.e. Free, Busy (default), busy-Tentative, OutOfOffice (busy-unavailable)
     *
     * @param  FreeBusyStatus $fb
     * @return FreeBusyStatus|self
     */
    public function fb(FreeBusyStatus $fb = null)
    {
        if(null === $fb)
        {
            return $this->property('fb');
        }
        return $this->property('fb', $fb);
    }

    /**
     * Gets or sets transparency
     * Valid values: O|T. i.e. Opaque or Transparent
     *
     * @param  Transparency $transp
     * @return Transparency|self
     */
    public function transp(Transparency $transp = null)
    {
        if(null === $transp)
        {
            return $this->property('transp');
        }
        return $this->property('transp', $transp);
    }

    /**
     * Gets or sets isOrg
     *
     * @param  boolean $isOrg
     * @return boolean|self
     */
    public function isOrg($isOrg = null)
    {
        if(null === $isOrg)
        {
            return $this->property('isOrg');
        }
        return $this->property('isOrg', (bool) $isOrg);
    }

    /**
     * Gets or sets x_uid
     *
     * @param  string $x_uid
     * @return string|self
     */
    public function x_uid($x_uid = null)
    {
        if(null === $x_uid)
        {
            return $this->property('x_uid');
        }
        return $this->property('x_uid', trim($x_uid));
    }

    /**
     * Gets or sets uid
     *
     * @param  string $uid
     * @return string|self
     */
    public function uid($uid = null)
    {
        if(null === $uid)
        {
            return $this->property('uid');
        }
        return $this->property('uid', trim($uid));
    }

    /**
     * Gets or sets seq
     *
     * @param  int $seq
     * @return int|self
     */
    public function seq($seq = null)
    {
        if(null === $seq)
        {
            return $this->property('seq');
        }
        return $this->property('seq', (int) $seq);
    }

    /**
     * Gets or sets d
     *
     * @param  int $d
     * @return int|self
     */
    public function d($d = null)
    {
        if(null === $d)
        {
            return $this->property('d');
        }
        return $this->property('d', (int) $d);
    }

    /**
     * Gets or sets calItemId
     *
     * @param  string $calItemId
     * @return string|self
     */
    public function calItemId($calItemId = null)
    {
        if(null === $calItemId)
        {
            return $this->property('calItemId');
        }
        return $this->property('calItemId', trim($calItemId));
    }

    /**
     * Gets or sets apptId
     *
     * @param  string $apptId
     * @return string|self
     */
    public function apptId($apptId = null)
    {
        if(null === $apptId)
        {
            return $this->property('apptId');
        }
        return $this->property('apptId', trim($apptId));
    }

    /**
     * Gets or sets ciFolder
     *
     * @param  string $ciFolder
     * @return string|self
     */
    public function ciFolder($ciFolder = null)
    {
        if(null === $ciFolder)
        {
            return $this->property('ciFolder');
        }
        return $this->property('ciFolder', trim($ciFolder));
    }

    /**
     * Gets or sets status
     * Valid values: TENT|CONF|CANC|NEED|COMP|INPR|WAITING|DEFERRED
     * i.e. TENTative, CONFirmed, CANCelled, COMPleted, INPRogress, WAITING, DEFERRED where waiting and Deferred are custom values not found in the iCalendar spec.
     *
     * @param  InviteStatus $status
     * @return InviteStatus|self
     */
    public function status(InviteStatus $status = null)
    {
        if(null === $status)
        {
            return $this->property('status');
        }
        return $this->property('status', $status);
    }

    /**
     * Gets or sets class
     * Valid values: PUB|PRI|CON
     *
     * @param  InviteClass $class
     * @return InviteClass|self
     */
    public function class_(InviteClass $class = null)
    {
        if(null === $class)
        {
            return $this->property('class');
        }
        return $this->property('class', $class);
    }

    /**
     * Gets or sets url
     *
     * @param  string $url
     * @return string|self
     */
    public function url($url = null)
    {
        if(null === $url)
        {
            return $this->property('url');
        }
        return $this->property('url', trim($url));
    }

    /**
     * Gets or sets ex
     *
     * @param  boolean $ex
     * @return boolean|self
     */
    public function ex($ex = null)
    {
        if(null === $ex)
        {
            return $this->property('ex');
        }
        return $this->property('ex', (bool) $ex);
    }

    /**
     * Gets or sets ridZ
     *
     * @param  string $ridZ
     * @return string|self
     */
    public function ridZ($ridZ = null)
    {
        if(null === $ridZ)
        {
            return $this->property('ridZ');
        }
        return $this->property('ridZ', trim($ridZ));
    }

    /**
     * Gets or sets allDay
     *
     * @param  bool $allDay
     * @return bool|self
     */
    public function allDay($allDay = null)
    {
        if(null === $allDay)
        {
            return $this->property('allDay');
        }
        return $this->property('allDay', (bool) $allDay);
    }

    /**
     * Gets or sets draft
     *
     * @param  boolean $draft
     * @return boolean|self
     */
    public function draft($draft = null)
    {
        if(null === $draft)
        {
            return $this->property('draft');
        }
        return $this->property('draft', (bool) $draft);
    }

    /**
     * Gets or sets neverSent
     *
     * @param  boolean $neverSent
     * @return boolean|self
     */
    public function neverSent($neverSent = null)
    {
        if(null === $neverSent)
        {
            return $this->property('neverSent');
        }
        return $this->property('neverSent', (bool) $neverSent);
    }

    /**
     * Add in invite change
     * Valid values: subject|location|time|recurrence
     *
     * @param  InviteChange $change
     * @return self
     */
    public function addChange(InviteChange $change)
    {
        $this->_changes->add($change);
        return $this;
    }

    /**
     * Get string of change
     *
     * @return string
     */
    public function changes()
    {
        return count($this->_changes) ? implode(',', $this->_changes->all()) : '';
    }

    /**
     * Returns the array representation of this class
     *
     * @param  string $name
     * @return array
     */
    public function toArray($name = 'comp')
    {
        return parent::toArray($name);
    }

    /**
     * Method returning the xml representation of this class
     *
     * @param  string $name
     * @return SimpleXML
     */
    public function toXml($name = 'comp')
    {
        return parent::toXml($name);
    }
}


text:
from __future__ import with_statement

import time, select, errno

from gearman.compat import *
from gearman.connection import GearmanConnection
from gearman.task import Task, Taskset
from gearman.client import GearmanClient

from twisted.internet import abstract, defer, reactor

class _ConnectionWrapper(abstract.FileDescriptor):
    def __init__(self, conn, onRead, *args, **kwargs):
        abstract.FileDescriptor.__init__(self, *args, **kwargs)
        self.conn = conn
        self.onRead = onRead
        self.reading = False
        self.writing = False

    def startReading(self):
        if not self.reading:
            reactor.addReader(self)
            self.reading = True

    def stopReading(self):
        if self.reading:
            reactor.removeReader(self)
            self.reading = False

    def startWriting(self):
        if not self.writing:
            reactor.addWriter(self)
            self.writing = True

    def stopWriting(self):
        if self.writing:
            reactor.removeWriter(self)
            self.writing = False

    def setState(self):
        if self.conn.readable():
            self.startReading()
        else:
            self.stopReading()
        if self.conn.writable():
            self.startWriting()
        else:
            self.stopWriting()

    def __enter__(self):
        self.setState()

    def __exit__(self, type, value, traceback):
        self.stopReading()
        self.stopWriting()

    def doWrite(self):
        self.conn.send()
        self.setState()

    def doRead(self):
        for cmd in self.conn.recv():
            self.onRead(*cmd)
        self.setState()

    def fileno(self):
        return self.conn.fileno()

class Client(GearmanClient):
    @defer.inlineCallbacks
    def do_task(self, task):
        """Return the result of the task or raise a TaskFailed exception on failure."""

        rtn = defer.Deferred()

        def _on_fail():
            rtn.errback(self.TaskFailed("Task failed"))

        task.on_fail.append(_on_fail)
        task.on_complete.append(rtn.callback)

        taskset = Taskset([task])
        taskset.handles = {}

        c = self._submit_task(task)
        taskset.connections = set([c])

        def _do_cmd(*args):
            return self._command_handler(taskset, c, *args)

        with _ConnectionWrapper(c, _do_cmd):
            rtn = yield rtn

        defer.returnValue(rtn)

    def dispatch_background_task(self, func, arg, uniq=None, high_priority=False):
        assert False, 'Not Implemented, use do_task(...)'

    def do_taskset(self, taskset, timeout=None):
        assert False, 'Not Implemented, use do_task(...) and DeferredList()'

    def get_status(self, handle):
        assert False, 'Not Implemented'


text:
<form>

Agrega una nueva tarea

        <input type="text" class="form-control" placeholder="Tarea a realizar" ng-model="tarea.nombre"> </input>

         Elige la prioridad:

            <input type="radio" ng-model="tarea.prioridad" value="0"> Baja

            <input type="radio" ng-model="tarea.prioridad" value="1"> Normal

            <input type="radio" ng-model="tarea.prioridad" value="2"> Alta

    <button type="submit" class="btn btn-success" ng-click="agregar()">Agregar</button>
</form>

Tareas registradas

        Prioridad: {{prioridades[tarea.attributes.prioridad]}} |

             Tarea: {{tarea.attributes.nombre}}


text:
package me.jessyan.mvparms.demo.mvp.model;

import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;

import java.util.List;

import javax.inject.Inject;

import io.rx_cache.DynamicKey;
import io.rx_cache.EvictDynamicKey;
import io.rx_cache.Reply;
import me.jessyan.mvparms.demo.mvp.contract.UserContract;
import me.jessyan.mvparms.demo.mvp.model.api.cache.CommonCache;
import me.jessyan.mvparms.demo.mvp.model.api.service.UserService;
import me.jessyan.mvparms.demo.mvp.model.entity.User;
import rx.Observable;
import rx.functions.Func1;

/**
 * Created by jess on 9/4/16 10:56
 * Contact with jess.yan.effort@gmail.com
 */
@ActivityScope
public class UserModel extends BaseModel implements UserContract.Model {
    public static final int USERS_PER_PAGE = 10;

    @Inject
    public UserModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);
    }

    @Override
    public Observable<List<User>> getUsers(int lastIdQueried, boolean update) {
        Observable<List<User>> users = mRepositoryManager.obtainRetrofitService(UserService.class)
                .getUsers(lastIdQueried, USERS_PER_PAGE);
        //使用rxcache缓存,上拉刷新则不读取缓存,加载更多读取缓存
        return mRepositoryManager.obtainCacheService(CommonCache.class)
                .getUsers(users
                        , new DynamicKey(lastIdQueried)
                        , new EvictDynamicKey(update))
                .flatMap(new Func1<Reply<List<User>>, Observable<List<User>>>() {
                    @Override
                    public Observable<List<User>> call(Reply<List<User>> listReply) {
                        return Observable.just(listReply.getData());
                    }
                });
    }

}


text:
/* jshint indent: 2 */

module.exports = function(sequelize, DataTypes) {
  return sequelize.define('ZC_MyAccount', {
    MyAccountID: {
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true,
      autoIncrement: true
    },
    UserID: {
      type: DataTypes.INTEGER,
      allowNull: false,
      references: {
        model: 'UserInfo',
        key: 'UserID'
      }
    },
    AvailableBalance: {
      type: DataTypes.STRING,
      allowNull: false,
      defaultValue: "((0))"
    },
    FreezingAmount: {
      type: DataTypes.STRING,
      allowNull: false,
      defaultValue: "((0))"
    },
    Type: {
      type: DataTypes.INTEGER,
      allowNull: false,
      defaultValue: "((0))"
    }
  }, {
    tableName: 'ZC_MyAccount'
  });
};


text:
@implementation HLFileServiceErrorCodes

static int _BASE_ERROR_CODE;

static int _FILE_SERVICE_ERROR_CODE;
static int _PUSH_FILE_JOB_ERROR_CODE;
static int _FILE_JOB_MANAGER_ERROR_CODE;

+(void)initialize {

    _BASE_ERROR_CODE = [CAErrorCodeUtilities getBaseErrorCode:[HLFileServiceConstants SERVICE_NAME]];

    _FILE_SERVICE_ERROR_CODE = _BASE_ERROR_CODE;
    _PUSH_FILE_JOB_ERROR_CODE = _BASE_ERROR_CODE | 0x10;
    _FILE_JOB_MANAGER_ERROR_CODE = _BASE_ERROR_CODE | 0x20;

}

+(int)getFileServiceErrorCode {
    return _FILE_SERVICE_ERROR_CODE;
}

+(int)getPushFileJobErrorCode {
    return _PUSH_FILE_JOB_ERROR_CODE;
}

+(int)getFileJobManagerErrorCode {
    return _FILE_JOB_MANAGER_ERROR_CODE;
}

@end


text:
package org.apache.flink.runtime.rest.messages.json;

import org.apache.flink.util.SerializedValue;
import org.apache.flink.util.TestLogger;

import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.type.TypeReference;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JavaType;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.module.SimpleModule;

import org.junit.Before;
import org.junit.Test;

import java.io.Serializable;

import static org.junit.Assert.assertEquals;

/**
 * Tests for {@link SerializedValueSerializer} and {@link SerializedValueDeserializer}.
 */
public class SerializedValueSerializerTest extends TestLogger {

	private ObjectMapper objectMapper;

	@Before
	public void setUp() {
		objectMapper = new ObjectMapper();
		final SimpleModule simpleModule = new SimpleModule();
		final JavaType serializedValueWildcardType = objectMapper
			.getTypeFactory()
			.constructType(new TypeReference<SerializedValue<?>>() {
			});
		simpleModule.addSerializer(new SerializedValueSerializer(serializedValueWildcardType));
		simpleModule.addDeserializer(
			SerializedValue.class,
			new SerializedValueDeserializer(serializedValueWildcardType));
		objectMapper.registerModule(simpleModule);
	}

	@Test
	public void testSerializationDeserialization() throws Exception {
		final String json = objectMapper.writeValueAsString(new SerializedValue<>(new TestClass()));

		final SerializedValue<TestClass> serializedValue =
			objectMapper.readValue(json, new TypeReference<SerializedValue<TestClass>>() {
			});
		final TestClass deserializedValue =
			serializedValue.deserializeValue(ClassLoader.getSystemClassLoader());

		assertEquals("baz", deserializedValue.foo);
		assertEquals(1, deserializedValue.bar);
	}

	private static class TestClass implements Serializable {

		private static final long serialVersionUID = 1L;

		private String foo = "baz";

		private int bar = 1;

	}

}


text:
/**
 * @license Highcharts JS v8.0.4 (2020-03-10)
 * @module highcharts/modules/export-data
 * @requires highcharts
 * @requires highcharts/modules/exporting
 *
 * Exporting module
 *
 * (c) 2010-2019 Torstein Honsi
 *
 * License: www.highcharts.com/license
 */
'use strict';
import '../../modules/export-data.src.js';


text:
<?php

class MessageController extends BaseController {

	public $restful = true;

    public function store() {
        $input = Input::all();
		$message = '';

        $user = Token::userFor ( Input::get('token') );
        if ( empty($user) ) {
            return ApiResponse::errorNotFound(Helper::failResponseFormat(array('User not found.')));
        }

        // Check user is account plus or not
        $plus = Plus::where('user_id', $user->_id)->where('end_date', '>=', date("Y-m-d H:i:s"))->first();
        $userHasPlus = false;
        if ($plus) {
            $userHasPlus = true;
        }

        $input['sender_id'] = $user->_id;

        Validator::extend('validate_sender_id', function($attribute, $value, $parameters)
        {
            if (!empty($parameters[0]) && !empty($value)) {
                $conversationObject =  Conversation::where('_id', $value)->first();
                if ($conversationObject) {
                    if (($conversationObject->creator_id == $parameters[0])
                            || ($conversationObject->joiner_id == $parameters[0]))
                    return true;
                }
            }

            return false;
        });

        Validator::replacer('validate_sender_id', function($message, $attribute, $rule, $params) {
            return 'You are not in this conversation and are not allowed to post message';
        });

		$validator = Validator::make( $input, Message::getCreateRules($input) );

		if ( $validator->passes() ) {

            // count message in conversation
            $countMessageCreated = Message::where('conversation_id', $input['conversation_id'])->where('sender_id', $user->_id)->get();

            if ($userHasPlus == false) {
                if (count($countMessageCreated) >= 10) {
                    return ApiResponse::errorForbidden(Helper::failResponseFormat (array('Normal user can only send maximum of 10 messages, upgrade your account to plus!')));
                }
            }

			$message = new Message();

			$message->sender_id = $input['sender_id'];
            $message->conversation_id = $input['conversation_id'];
            $message->content = $input['content'];
            $message->is_new = 1;

            if ( !$message->save() ) {
				return ApiResponse::errorInternal(Helper::failResponseFormat (array('An error occured. Please, try again.')));
            }

		}
		else {
			$error = Helper::getErrorMessageValidation($validator);
			return ApiResponse::errorValidation(Helper::failResponseFormat($error));
		}
        $returnMessage = Message::find($message->_id);

        $returnMessage->sender = User::find($message->sender_id);
        $returnMessage->conversation = Conversation::find($message->conversation_id);

		return ApiResponse::json(Helper::successResponseFormat(null, $returnMessage->toArray()));
    }

    public function index() {
        $input = Input::all();

        $query = $this->processInput();

        $currentUser = Token::userFor(Input::get('token'));

        if (!isset($input['conversation_id']) || empty($input['conversation_id'])) {
            return ApiResponse::errorNotFound(Helper::failResponseFormat(array('Conversation found!')));
        }

        $conversation = Conversation::where('_id', $input['conversation_id'])->first();
        if (empty($conversation)) {
            return ApiResponse::errorNotFound(Helper::failResponseFormat(array('Conversation found!')));
        }

        if (($conversation->creator_id != $currentUser->_id) && ($conversation->joiner_id != $currentUser->_id)) {
            return ApiResponse::errorForbidden(Helper::failResponseFormat(array('Permission denied!')));
        }

        $result = Message::getAll($query['where'], $query['sort'], $query['limit'], $query['offset']);

        if (count($result) > 0) {
            // Add User info to event list
            foreach ($result as $id=>$object) {
                $sender = User::find($object->sender_id);
                $sender->photos;

                $object->sender = $sender->toArray();

                // mark message is_new = 0 if sender_id != current user id
                $message = Message::find($object->_id);
                if ($message->sender_id != $currentUser->_id) {
                    $message->is_new = 0;
                    $message->save();
                }
            }

            // TODO: optimize
            foreach ($result as $id=>$object) {
                if(!empty($query['fields'])) {
                    foreach ($object as $key=>$value) {
                        if(in_array($key, $query['fields'])) {
                            continue;
                        } else {
                            unset($object->$key);
                        }
                    }
                }
            }

        }

        return ApiResponse::json(Helper::successResponseFormat(null, $result));

	}

	public function missingMethod( $parameters = array() )
	{
	    return ApiResponse::errorNotFound(Helper::failResponseFormat(array('Sorry, no method found')));
	}

}


text:
using System;
using System.Collections.ObjectModel;
using System.Diagnostics.Contracts;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;

namespace Rikrop.Core.Wcf
{
    public class ApplyErrorHandlerServiceBehavior : IServiceBehavior
    {
        private readonly IErrorHandler _errorHandler;

        public ApplyErrorHandlerServiceBehavior(IErrorHandler errorHandler)
        {
            Contract.Requires<ArgumentNullException>(errorHandler != null);

            _errorHandler = errorHandler;
        }

        public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
        {

        }

        public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters)
        {

        }

        public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
        {
            foreach (ChannelDispatcher dispatcher in serviceHostBase.ChannelDispatchers)
            {
                dispatcher.ErrorHandlers.Add(_errorHandler);
            }
        }
    }
}


text:
module Skellington
  describe CLI do
    let :subject do
      described_class.new
    end

    it 'generates a config/config.yml file' do
      subject.generate 'dummy-app'
      expect('dummy_app/config/config.yml').to have_content (
      """
      #google-analytics-tag: UA-00000000-0
      #github_url: https://github.com # also uncomment the `include` line in `styles.scss`
      """
      )
    end
  end
end


text:
Depending on the type of issue, please include the follwing information:
- Node and NPM Version
  - `node -v`
  - `npm -v`
- Server OS Version / Distribution / Processor Architecture
  - `uname -a`
  - `cat /etc/os-release`
- WebSSH2 release version
  - `grep version app/package.json`
- OS and Version of SSH server connecting to
  - `uname -a`
  - `sshd -v`
- Browser Version and OS
  - Information from brwoser's About... or a screenshot of the about screen.
- Any log or messages from the WebSSH2 output


text:
{-# OPTIONS_GHC -fno-warn-orphans #-}

{-|
Module:      Instances.Data.Dynamic
Copyright:   (C) 2014-2017 Ryan Scott
License:     BSD-style (see the file LICENSE)
Maintainer:  Ryan Scott
Stability:   Provisional
Portability: GHC

'Arbitrary' instance for 'Dynamic'.
-}
module Instances.Data.Dynamic () where

import Data.Dynamic (Dynamic, toDyn)

import Prelude ()
import Prelude.Compat

import Test.QuickCheck (Arbitrary(..), Gen)

instance Arbitrary Dynamic where
    arbitrary = toDyn <$> (arbitrary :: Gen Int)


text:
<?php

namespace common\models\Search;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Order;

/**
 * OrderSearch represents the model behind the search form about `common\models\Order`.
 */
class OrderSearch extends Order
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'address_id', 'user_id'], 'integer'],
            [['email', 'notes', 'status', 'payment_type_id'], 'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = Order::find();

        // add conditions that should always apply here

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'id'              => $this->id,
            'address_id'      => $this->address_id,
            'user_id'         => $this->user_id,
            'payment_type_id' => $this->payment_type_id,
        ]);

        $query->andFilterWhere(['like', 'email', $this->email])
            ->andFilterWhere(['like', 'notes', $this->notes])
            ->andFilterWhere(['like', 'status', $this->status]);

        return $dataProvider;
    }
}


text:
#include "mexutil.h"

/* Functions to create uninitialized arrays. */

mxArray *mxCreateNumericArrayE(mwSize ndim, const mwSize *dims,
         mxClassID classid, mxComplexity ComplexFlag)
{
  mxArray *a;
  mwSize i;
  mwSize *dims1 = mxMalloc(ndim*sizeof(mwSize));
  mwSize sz = 1;
  for(i=0;i<ndim;i++) {
    sz *= dims[i];
    dims1[i] = 1;
  }
  a = mxCreateNumericArray(ndim,dims1,classid,ComplexFlag);
  sz *= mxGetElementSize(a);
  mxSetDimensions(a, dims, ndim);
  mxFree(dims1);
  mxSetData(a, mxRealloc(mxGetData(a), sz));
  if(ComplexFlag == mxCOMPLEX) {
    mxSetPi(a, mxRealloc(mxGetPi(a),sz));
  }
  return a;
}
mxArray *mxCreateNumericMatrixE(mwSize m, mwSize n, mxClassID classid,
				mxComplexity ComplexFlag)
{
  mwSize sz = m*n*sizeof(double);
  mxArray *a = mxCreateNumericMatrix(1, 1, classid, ComplexFlag);
  mxSetM(a,m);
  mxSetN(a,n);
  mxSetPr(a, mxRealloc(mxGetPr(a),sz));
  if(ComplexFlag == mxCOMPLEX) {
    mxSetPi(a, mxRealloc(mxGetPi(a),sz));
  }
  return a;
}
mxArray *mxCreateDoubleMatrixE(mwSize m, mwSize n,
			       mxComplexity ComplexFlag)
{
  return mxCreateNumericMatrixE(m,n,mxDOUBLE_CLASS,ComplexFlag);
}


text:
layout: page
title: "Trail Wallet FAQ"
date: 2015-04-22 10:59
comments: true
sharing: true
liking: false
footer: true
sidebar: false
---

# Good Day To You, Walleteer!

We are Erin and Simon from [Never Ending Voyage][1] and we want to thank you for trying out our app. We have been travelling non-stop for seven years and part of how we support ourselves is through Trail Wallet.