Beispiel #1
0
AttribFreehand::AttribFreehand ()
: AttribView (BRect (0, 0, 148, 40), lstring (27, "Freehand"))
{
	SetViewColor (LightGrey);
	pSlid = new Slider (BRect (8, 8, 140, 26), 60, lstring (310, "Pen Size"), 1, 50, 1, new BMessage ('AFpc'));
	AddChild (pSlid);
	fPenSize = 1;
	fCurrentProperty = 0;
}
Beispiel #2
0
void SAboutView::Draw (BRect updateRect)
{
	if (updateRect != BRect (85, 170, 250, 195))
	{
		if (fBecasso)
			DrawBitmap (fBecasso, BPoint (25, 10));
		if (fSum)
			DrawBitmap (fSum, BPoint (10, 115));
		SetLowColor (Grey28);
		SetHighColor (Grey8);
		char verstring[80];
		extern const char *Version;
		extern int gGlobalAlpha;
		extern char gAlphaMask[128];
		SetFontSize (13);
		sprintf (verstring, lstring (3, "Version %s, built %s"), Version, __DATE__);
	//	sprintf (verstring, "MacWorld Demo Version");
		DrawString (verstring, BPoint (85, 124));
		SetFontSize (11);
		DrawString ("© 1997-2001 ∑ Sum Software", BPoint (85, 138));
		if (!gGlobalAlpha)
		{
			SetHighColor (Red);
			SetFontSize (13);
			DrawString (lstring (4, "Unregistered Version"), BPoint (85, 155));
		}
		else
		{
			SetHighColor (Grey8);
			#if defined(__HAIKU__)
			DrawString ("Released under the MIT license", BPoint (85, 152));
			#else
			DrawString (lstring (7, "Registered to"), BPoint (85, 152));
			SetHighColor (Black);
			SetFontSize (12);
			DrawString (gAlphaMask, BPoint (85, 168));
			#endif
		}
	//	DrawString ("Add-On developers beta version", BPoint (85, 158));
	//	DrawString ("This is a ", BPoint (85, 158));
	//	SetHighColor (Red);
	//	DrawString ("time limited");
	//	SetHighColor (Grey8);
	//	DrawString (" demo that will");
	//	DrawString ("stop working on January 1st, 1998", BPoint (85, 172));
	}
	if (fStartup)
	{
		SetLowColor (Grey28);
		SetHighColor (Grey8);
		SetFontSize (12);
		DrawString (lstring (5, "Initializing Add-Ons:"), BPoint (85, 182));
		SetFontSize (11);
		DrawString (fAddOnString, BPoint (85, 194));
	}
}
Beispiel #3
0
int program(struct parser* p)
{
    lstring(p, ".SYNTAX");
    identifier(p);
    out2("ADR", p->id);

    while (st(p)) {}

    if (lstring(p, ".END")) {
        out1("END");
        return 1;
    }
    return 1;
}
Beispiel #4
0
AttribBrush::AttribBrush ()
: AttribView (BRect (0, 0, 160, 280), lstring (22, "Brush"))
{
	SetViewColor (LightGrey);
	fSpacing = 1;
	fAngle = 0;
	fX = 5;
	fY = 5;
	fHardness = 1;
	fStrength = 128;
	fBrush = NULL;
	bv = new BitmapView (BRect (4, 4, 154, 154), "BrushBitmapView");
	AddChild (bv);
	ConstructBrush();
	xSlid = new Slider (BRect (4, 160, 154, 176), 60, lstring (300, "X-size"), 1, 40, 1, new BMessage ('ABxc'), B_HORIZONTAL, 26);
	ySlid = new Slider (BRect (4, 180, 154, 196), 60, lstring (301, "Y-size"), 1, 40, 1, new BMessage ('AByc'), B_HORIZONTAL, 26);
	aSlid = new Slider (BRect (4, 200, 154, 216), 60, lstring (302, "Angle"), 0, 45, 1, new BMessage ('ABac'), B_HORIZONTAL, 26);
	sSlid = new Slider (BRect (4, 220, 154, 236), 60, lstring (303, "Strength"), 0, 255, 1, new BMessage ('ABsc'), B_HORIZONTAL, 26);
	hSlid = new Slider (BRect (4, 240, 154, 256), 60, lstring (305, "Hardness"), 1, 100, 1, new BMessage ('ABph'), B_HORIZONTAL, 26);
	pSlid = new Slider (BRect (4, 260, 154, 276), 60, lstring (304, "Spacing"), 1, 64, 1, new BMessage ('ABpc'), B_HORIZONTAL, 26);
	AddChild (xSlid);
	AddChild (ySlid);
	AddChild (aSlid);
	AddChild (sSlid);
	AddChild (hSlid);
	AddChild (pSlid);
	xSlid->SetValue (fX);
	ySlid->SetValue (fY);
	sSlid->SetValue (fStrength);
	hSlid->SetValue (fHardness);
	fCurrentProperty = 0;
}
Beispiel #5
0
SAboutView::SAboutView (BRect rect, BBitmap *becasso, BBitmap *sum, bool startup)
: BView (rect, "SAboutView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW)
{
	fBecasso = becasso;
	fSum = sum;
	SetViewColor (Grey28);
	fStartup = startup;
	fAddOnString[0] = 0;
	url = NULL;
	doc = NULL;
	if (!startup)
	{
		url = new BButton (BRect (126, 178, 196, 196), "url", lstring (1, "URL"), new BMessage ('aURL'));
		doc = new BButton (BRect (204, 178, 274, 196), "doc", lstring (2, "Manual"), new BMessage ('aDOC'));
		url->SetTarget (be_app);
		doc->SetTarget (be_app);
		AddChild (url);
		AddChild (doc);
	}
}
Beispiel #6
0
int output(struct parser* p)
{
    if (lstring(p, ".OUT")) {
        lstring(p, "(");
        while (output1(p)) {}
        lstring(p, ")");
        out1("OUT");
    }
    else if (lstring(p, ".LABEL")) {
        out1("LB");
        output1(p);
        out1("OUT");
    }
    else {
        //out1("OUT");
        return 0;
    }

    return 1;
}
Beispiel #7
0
int output1(struct parser* p)
{
    whitespace(p);

    if (lstring(p, "*1")) {
        out1("GN1");
        return 1;
    }
    else if (lstring(p, "*2")) {
        out1("GN2");
        return 1;
    }
    else if (lstring(p, "*")) {
        out1("CI");
        return 1;
    }
    else if (string(p)) {
        out2("CL", p->id);
        return 1;
    }
    return 0;
}
Beispiel #8
0
int st(struct parser* p)
{
    if (!identifier(p)) {
        return 0;
    }

    label(p->id);

    character(p, '=');
    ex1(p);
    lstring(p, ".,");
    out1("R");

    return 1;
}
Beispiel #9
0
AttribFill::AttribFill ()
: AttribView (BRect (0, 0, 146, 146), lstring (24, "Fill"))
{
	SetViewColor (LightGrey);
	BBox *tolSets = new BBox (BRect (4, 4, 142, 142), "tol");
	tolSets->SetLabel (lstring (338, "Tolerance"));
	AddChild (tolSets);
	tol = new BRadioButton (BRect (8, 13, 124, 30), "tol", lstring (339, "Visual Distance"), new BMessage ('AFtV'));
	rgb = new BRadioButton (BRect (8, 30, 124, 46), "rgb", lstring (340, "Absolute RGB"), new BMessage ('AFtS'));
	tol->SetValue (B_CONTROL_ON);
	tolSets->AddChild (tol);
	tolSets->AddChild (rgb);
	TabView *bgTab = new TabView (BRect (4, 50, 132, 134), "AttribFill Tab");
	tolSets->AddChild (bgTab);
	BView *tolTab = new BView (BRect (2, TAB_HEIGHT + 4, 126, TAB_HEIGHT + 63), "tol View", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
	BView *rgbTab = new BView (BRect (2, TAB_HEIGHT + 4, 126, TAB_HEIGHT + 63), "rgb View", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
	tolTab->SetViewColor (LightGrey);
	rgbTab->SetViewColor (LightGrey);
	bgTab->AddView (tolTab, lstring (341, "Visual"));
	bgTab->AddView (rgbTab, lstring (342, "RGB"));
	BStringView *explD = new BStringView (BRect (2, 8, 122, 20), "explD", lstring (343, "Visual Factors:"));
	BStringView *facD = new BStringView (BRect (2, 20, 122, 32), "facD", lstring (344, "R: 0.213 G: 0.715 B: 0.072"));
	explD->SetFontSize (10);
	facD->SetFontSize (10);
	sT = new Slider (BRect (4, 42, 122, 58), 10, "D", 0, 255, 1, new BMessage ('AFcT'));
	sR = new Slider (BRect (4,  2, 122, 18), 10, "R", 0, 255, 1, new BMessage ('AFcR'));
	sG = new Slider (BRect (4, 22, 122, 38), 10, "G", 0, 255, 1, new BMessage ('AFcG'));
	sB = new Slider (BRect (4, 42, 122, 58), 10, "B", 0, 255, 1, new BMessage ('AFcB'));
	tolTab->AddChild (sT);
	tolTab->AddChild (explD);
	tolTab->AddChild (facD);
	rgbTab->AddChild (sR);
	rgbTab->AddChild (sG);
	rgbTab->AddChild (sB);
	fTolMode = FILLTOL_TOL;
	fTolerance = 0;
	fToleranceRGB.red = 0;
	fToleranceRGB.green = 0;
	fToleranceRGB.blue = 0;
	fCurrentProperty = 0;
}
Beispiel #10
0
int ex1(struct parser* p)
{
    int alt_count=1;
    int label_1 = label_count++;

    printf("                              ; alternation %d\n", alt_count);
    ex2(p);

    while (lstring(p, "/")) {
        alt_count++;
        printf("                              ; alternation %d\n", alt_count);

        out3("BT", label_1);

        if (!ex2(p)) break;
    }
    generate_label(label_1);

    return 1;
}
Beispiel #11
0
MagWindow::MagWindow (BRect frame, const char *name, CanvasView *_myView)
: BWindow (frame, name, B_DOCUMENT_WINDOW, 0, 0)
{
	BRect viewFrame, hFrame, vFrame, menubarFrame;
	menubarFrame.Set (0, 0, 0, 0);
	menubar = new BMenuBar (menubarFrame, "Magnify Menubar");
	BPopUpMenu *zoomMenu = new BPopUpMenu ("");
	zoomMenu->AddItem (new BMenuItem ("1:2", new BMessage ('zm2')));
	zoomMenu->AddItem (new BMenuItem ("1:4", new BMessage ('zm4')));
	zoomMenu->AddItem (new BMenuItem ("1:8", new BMessage ('zm8')));
	zoomMenu->AddItem (new BMenuItem ("1:16", new BMessage ('zm16')));
	zoomMenu->FindItem('zm8')->SetMarked (true);
	menubar->AddItem (zoomMenu);
	BPopUpMenu *gridMenu = new BPopUpMenu ("");
	gridMenu->AddItem (new BMenuItem (lstring (410, "Grid off"), new BMessage ('grd0')));
	gridMenu->AddItem (new BMenuItem (lstring (411, "Grid B"), new BMessage ('grdB')));
	gridMenu->AddItem (new BMenuItem (lstring (412, "Grid W"), new BMessage ('grdW')));
	gridMenu->FindItem('grdB')->SetMarked (true);
	menubar->AddItem (gridMenu);
	editMenu = new BMenu (lstring (60, ""));
	editMenu->AddItem (new BMenuItem (lstring (61, "Undo"), new BMessage (B_UNDO), 'Z'));
	editMenu->AddItem (new BMenuItem (lstring (62, "Redo"), new BMessage ('redo'), 'Z', B_SHIFT_KEY));
	menubar->AddItem (editMenu);
	AddChild (menubar);
	menubar->ResizeToPreferred();
	menubarFrame = menubar->Frame();
	menubarheight = menubarFrame.Height();
	viewFrame.Set (0, menubarheight + 1,
		frame.Width() - B_V_SCROLL_BAR_WIDTH,
		frame.Height() - B_H_SCROLL_BAR_HEIGHT);
	magView = new MagView (viewFrame, "Magnify View", _myView);
	hFrame.Set (0, frame.Height() - B_H_SCROLL_BAR_HEIGHT + 1,
		frame.Width() - B_V_SCROLL_BAR_WIDTH + 1,
		frame.Height() + 1);
	h = new BScrollBar (hFrame, NULL, magView, 0, 0, B_HORIZONTAL);
	vFrame.Set (frame.Width() - B_V_SCROLL_BAR_WIDTH + 1,
		menubarFrame.Height(), frame.Width() + 1,
		frame.Height() - B_H_SCROLL_BAR_HEIGHT + 1);
	v = new BScrollBar (vFrame, NULL, magView, 0, 0, B_VERTICAL);
	AddChild (h);
	AddChild (v);
	magView->setScrollBars (h, v);
	AddChild (magView);
	myWindow = _myView->Window();
	SetPulseRate (50000);
}
Beispiel #12
0
int ex3(struct parser* p)
{
    int label_1 = label_count++;

    whitespace(p);

    if (lstring(p, ".ID")) {
        out1("ID");
        return 1;
    }
    else if (lstring(p, ".NUMBER")) {
        out1("NUM");
        return 1;
    }
    else if (lstring(p, ".STRING")) {
        out1("SR");
        return 1;
    }
    else if (lstring(p, ".EMPTY")) {
        out1("SET");
        return 1;
    }
    else if (lstring(p, "(")) {
        ex1(p);
        lstring(p, ")");
        return 1;
    }
    else if (*(p->buf->begin) == '$') {
        p->buf->begin++;
        generate_label(label_1);
        ex3(p);
        out3("BT", label_1);
        out1("SET");
        return 1;
    }
    else if (identifier(p)) {
        out2("CLL", p->id);
        return 1;
    }
    else if (string(p)) {
        out2("TST", p->id);
        return 1;
    }
    return 0;
}
Beispiel #13
0
AttribPolygon::AttribPolygon ()
: AttribView (BRect (0, 0, 148, 90), lstring (30, "Polygons"))
{
	SetViewColor (LightGrey);
	lSlid = new Slider (BRect (8, 8, 140, 26), 60, lstring (310, "Pen Size"), 1, 50, 1, new BMessage ('ALpc'));
	AddChild (lSlid);
	fPenSize = 1;
	fType = POLYGON_OUTFILL;
	BBox *type = new BBox (BRect (18, 32, 130, 82), "type");
	type->SetLabel (lstring (311, "Type"));
	AddChild (type);

	BPoint pointArray[] = {
		BPoint ( 2,  8),
		BPoint ( 9,  2),
		BPoint (27, 12),
		BPoint (19, 28),
		BPoint (14, 20),
		BPoint ( 9, 26)
		};
	BPolygon *poly = new BPolygon();
	poly->AddPoints(pointArray, 6);

	BWindow *picWindow = new BWindow (BRect (0, 0, 100, 100), "Temp Pic Window", B_BORDERED_WINDOW, uint32 (NULL), uint32 (NULL));
	BView *bg = new BView (BRect (0, 0, 100, 100), "Temp Pic View", uint32 (NULL), uint32 (NULL));
	picWindow->AddChild (bg);
	
	BPicture *p10;
	bg->BeginPicture (new BPicture);
	bg->SetLowColor (LightGrey);
	bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
	bg->SetLowColor (White);
	bg->FillPolygon (poly, B_SOLID_LOW);
	bg->StrokePolygon (poly);
	p10 = bg->EndPicture();
	
	BPicture *p20;
	bg->BeginPicture (new BPicture);
	bg->SetLowColor (LightGrey);
	bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
	bg->SetHighColor (Black);
	bg->SetLowColor (White);
	bg->FillPolygon (poly, B_SOLID_LOW);
	p20 = bg->EndPicture();
	
	BPicture *p30;
	bg->BeginPicture (new BPicture);
	bg->SetLowColor (LightGrey);
	bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
	bg->SetHighColor (Black);
	bg->SetLowColor (White);
	bg->StrokePolygon (poly);
	p30 = bg->EndPicture();

	BPicture *p11;
	bg->BeginPicture (new BPicture);
	bg->SetLowColor (DarkGrey);
	bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
	bg->SetHighColor (Black);
	bg->SetLowColor (White);
	bg->FillPolygon (poly, B_SOLID_LOW);
	bg->StrokePolygon (poly);
	p11 = bg->EndPicture();
	
	BPicture *p21;
	bg->BeginPicture (new BPicture);
	bg->SetLowColor (DarkGrey);
	bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
	bg->SetHighColor (Black);
	bg->SetLowColor (White);
	bg->FillPolygon (poly, B_SOLID_LOW);
	p21 = bg->EndPicture();
	
	BPicture *p31;
	bg->BeginPicture (new BPicture);
	bg->SetLowColor (DarkGrey);
	bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
	bg->SetHighColor (Black);
	bg->SetLowColor (White);
	bg->StrokePolygon (poly);
	p31 = bg->EndPicture();
	
	delete poly;
	delete picWindow;
	
	SetViewColor (LightGrey);
	
	pT1 = new BPictureButton (BRect (4, 15, 34, 45), "APVt1", p10, p11, new BMessage ('pvT1'), B_TWO_STATE_BUTTON);
	pT2 = new BPictureButton (BRect (40, 15, 70, 45), "APVt2", p20, p21, new BMessage ('pvT2'), B_TWO_STATE_BUTTON);
	pT3 = new BPictureButton (BRect (76, 15, 106, 45), "APVt3", p30, p31, new BMessage ('pvT3'), B_TWO_STATE_BUTTON);
	type->AddChild (pT1);
	type->AddChild (pT2);
	type->AddChild (pT3);
	pT1->SetValue (B_CONTROL_ON);
	fCurrentProperty = 0;
}
Beispiel #14
0
AttribRect::AttribRect ()
    : AttribView (BRect (0, 0, 148, 90), lstring (31, "Rectangles"))
{
    SetViewColor (LightGrey);
    lSlid = new Slider (BRect (8, 8, 140, 26), 60, lstring (310, "Pen Size"), 1, 50, 1, new BMessage ('ALpc'));
    AddChild (lSlid);
    fType = RECT_OUTFILL;
    fPenSize = 1;
    BBox *type = new BBox (BRect (18, 32, 130, 82), "type");
    type->SetLabel (lstring (311, "Type"));
    AddChild (type);
    BRect shape = BRect (3, 5, 27, 25);

    BWindow *picWindow = new BWindow (BRect (0, 0, 100, 100), "Temp Pic Window", B_BORDERED_WINDOW, uint32 (NULL), uint32 (NULL));
    BView *bg = new BView (BRect (0, 0, 100, 100), "Temp Pic View", uint32 (NULL), uint32 (NULL));
    picWindow->AddChild (bg);

    BPicture *p10;
    bg->BeginPicture (new BPicture);
    bg->SetLowColor (LightGrey);
    bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
    bg->SetLowColor (White);
    bg->FillRect (shape, B_SOLID_LOW);
    bg->StrokeRect (shape);
    p10 = bg->EndPicture();

    BPicture *p20;
    bg->BeginPicture (new BPicture);
    bg->SetLowColor (LightGrey);
    bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
    bg->SetHighColor (Black);
    bg->SetLowColor (White);
    bg->FillRect (shape, B_SOLID_LOW);
    p20 = bg->EndPicture();

    BPicture *p30;
    bg->BeginPicture (new BPicture);
    bg->SetLowColor (LightGrey);
    bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
    bg->SetHighColor (Black);
    bg->SetLowColor (White);
    bg->StrokeRect (shape);
    p30 = bg->EndPicture();

    BPicture *p11;
    bg->BeginPicture (new BPicture);
    bg->SetLowColor (DarkGrey);
    bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
    bg->SetHighColor (Black);
    bg->SetLowColor (White);
    bg->FillRect (shape, B_SOLID_LOW);
    bg->StrokeRect (shape);
    p11 = bg->EndPicture();

    BPicture *p21;
    bg->BeginPicture (new BPicture);
    bg->SetLowColor (DarkGrey);
    bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
    bg->SetHighColor (Black);
    bg->SetLowColor (White);
    bg->FillRect (shape, B_SOLID_LOW);
    p21 = bg->EndPicture();

    BPicture *p31;
    bg->BeginPicture (new BPicture);
    bg->SetLowColor (DarkGrey);
    bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
    bg->SetHighColor (Black);
    bg->SetLowColor (White);
    bg->StrokeRect (shape);
    p31 = bg->EndPicture();

    SetViewColor (LightGrey);
    delete picWindow;

    pT1 = new BPictureButton (BRect (4, 15, 34, 45), "APVt1", p10, p11, new BMessage ('pvT1'), B_TWO_STATE_BUTTON);
    pT2 = new BPictureButton (BRect (40, 15, 70, 45), "APVt2", p20, p21, new BMessage ('pvT2'), B_TWO_STATE_BUTTON);
    pT3 = new BPictureButton (BRect (76, 15, 106, 45), "APVt3", p30, p31, new BMessage ('pvT3'), B_TWO_STATE_BUTTON);
    type->AddChild (pT1);
    type->AddChild (pT2);
    type->AddChild (pT3);
    pT1->SetValue (B_CONTROL_ON);
    fCurrentProperty = 0;
}
Beispiel #15
0
bool CHttpClient::Request(const TCHAR * pURL)
{
    bool bSuccess(false);
    if (pURL != NULL) {
        URL_COMPONENTS urlCom = {sizeof(URL_COMPONENTS),
                                 NULL, 1, INTERNET_SCHEME_DEFAULT,
                                 NULL, 1, 0,
                                 NULL, 1,
                                 NULL, 1,
                                 NULL, 1,
                                 NULL, 1,
                                };
        InternetCrackUrl(pURL, lstrlen(pURL), 0, &urlCom);
        mServer = urlCom.lpszHostName ? lstring(urlCom.lpszHostName, urlCom.dwHostNameLength) : pURL;
        mPort = urlCom.nPort;
        if (urlCom.lpszUrlPath)
            mPath = lstring(urlCom.lpszUrlPath, urlCom.dwUrlPathLength);
        if (urlCom.lpszUserName)
            mUserName = lstring(urlCom.lpszUserName, urlCom.dwUserNameLength);
        if (urlCom.lpszPassword)
            mPassword = lstring(urlCom.lpszPassword, urlCom.dwPasswordLength);
        SetHttps(urlCom.nScheme == INTERNET_SCHEME_HTTPS);
    }
    HINTERNET hi = InternetOpen(mUserAgent.c_str(), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
    if (hi != NULL) {
        if (!mPort)
            mPort = IsHttps() ? INTERNET_DEFAULT_HTTPS_PORT : INTERNET_DEFAULT_HTTP_PORT;
        HINTERNET hc = InternetConnect(hi, mServer.c_str(), mPort,
                                       GET_PTR_FROM_STR(mUserName), GET_PTR_FROM_STR(mPassword),
                                       INTERNET_SERVICE_HTTP, 0, 0);
        if (hc != NULL) {
            const TCHAR *rgpszAcceptTypes[] = { _T("*/*"), NULL};
            DWORD dwDword(INTERNET_FLAG_NO_UI);
            if (IsHttps())
                dwDword |= INTERNET_FLAG_SECURE;
            HINTERNET http = HttpOpenRequest(hc, GET_PTR_FROM_STR(mhttpVerb), mPath.c_str(), NULL, NULL, rgpszAcceptTypes,
                                             dwDword, NULL);
            if (http != NULL) {
                if (HttpSendRequest(http, GET_PTR_FROM_STR(mhttpHeaders), (DWORD)mhttpHeaders.length(), mDataToSend, (DWORD)mDataToSend.DataSize())) {
                    int statusCode(0);
                    {
                        wchar_t responseText[1024]; // change to wchar_t for unicode
                        DWORD responseTextSize = sizeof(responseText);

                        //Check existence of page (for 404 error)
                        if (!HttpQueryInfo(http,
                                           HTTP_QUERY_STATUS_CODE,
                                           &responseText,
                                           &responseTextSize,
                                           NULL))
                            statusCode = GetLastError();
                        else
                            STLUtils::ChangeType(lstring(responseText), statusCode);
                    }
                    BinaryData inDataRead(NULL, 1024*1024*4); // 4MB
                    while (InternetReadFile(http, inDataRead, (DWORD)inDataRead.Size(), &dwDword) && dwDword > 0)
                    {
                        bSuccess = true;
                        inDataRead.SetDataSize(dwDword);
                        if (!ContentHandler(inDataRead))
                            break;
                    }
                }
                InternetCloseHandle(http);
            }
            InternetCloseHandle(hc);
        }
        InternetCloseHandle(hi);
    }
    return bSuccess;
}
Beispiel #16
0
ResizeWindow::ResizeWindow (CanvasWindow *target, const char *title, int32 _h, int32 _w)
: BWindow (BRect (100, 100, 300, 248), title, B_TITLED_WINDOW, B_NOT_RESIZABLE)
{
	char hS[16], wS[16], rD[16];
	fTarget = target;
	fRez = 72;
	fH = _w;
	fV = _h;
	fHUnit = UNIT_PIXELS;
	fVUnit = UNIT_PIXELS;
	BRect bgFrame, cancelFrame, openFrame, textFrame, heightFrame, widthFrame, rezFrame;
	bgFrame = Bounds();
	BView *bg = new BView (bgFrame, "SW bg", B_FOLLOW_ALL, B_WILL_DRAW);
	bg->SetViewColor (LightGrey);
	AddChild (bg);

	textFrame.Set (8, 8, 192, 102);
	BBox *text = new BBox (textFrame, "SW box");
	text->SetLabel (lstring (180, "Canvas Size"));
	bg->AddChild (text);
	
#if 0
	textFrame.Set (8, 80, 192, 120);
	BBox *rez = new BBox (textFrame, "SW r box");
	rez->SetLabel (lstring (186, "Resolution"));
	bg->AddChild (rez);
#endif

	sprintf (hS, "%li", _h);
	sprintf (wS, "%li", _w);
	sprintf (rD, "%li", fRez);
	widthFrame.Set (8, 15, 120, 33);
	heightFrame.Set (8, 39, 120, 57);
	rezFrame.Set (8, 63, 120, 81);
	newWidth = new BTextControl (widthFrame, "NewWidth", lstring (181, "Width"), wS, new BMessage ('Swdt'));
	newHeight = new BTextControl (heightFrame, "NewHeight", lstring (182, "Height"), hS, new BMessage ('Shgt'));
	rDPI = new BTextControl (rezFrame, "rez", lstring (186, "Resolution"), rD, new BMessage ('Srez'));
	newHeight->SetAlignment (B_ALIGN_RIGHT, B_ALIGN_LEFT);
	newWidth->SetAlignment (B_ALIGN_RIGHT, B_ALIGN_LEFT);
	rDPI->SetAlignment (B_ALIGN_RIGHT, B_ALIGN_LEFT);
	BStringView *dpiV = new BStringView (BRect (rezFrame.right + 4, rezFrame.top, rezFrame.right + 40, rezFrame.bottom),
		"dpiV", "dpi");
	BPopUpMenu *hPU = new BPopUpMenu ("");
	hPU->AddItem (new BMenuItem (lstring (187, "pixels"), new BMessage ('h_px')));
	hPU->AddItem (new BMenuItem (lstring (188, "in"), new BMessage ('h_in')));
	hPU->AddItem (new BMenuItem (lstring (189, "cm"), new BMessage ('h_cm')));
	hPU->ItemAt(0)->SetMarked (true);
	BMenuField *hMF = new BMenuField (BRect (124, 14, 180, 30), "hUnit", NULL, hPU);
	BPopUpMenu *vPU = new BPopUpMenu ("");
	vPU->AddItem (new BMenuItem (lstring (187, "pixels"), new BMessage ('v_px')));
	vPU->AddItem (new BMenuItem (lstring (188, "in"), new BMessage ('v_in')));
	vPU->AddItem (new BMenuItem (lstring (189, "cm"), new BMessage ('v_cm')));
	vPU->ItemAt(0)->SetMarked (true);
	BMenuField *vMF = new BMenuField (BRect (124, 38, 180, 54), "vUnit", NULL, vPU);
		text->AddChild (newWidth);
	text->AddChild (hMF);
	text->AddChild (newHeight);
	text->AddChild (vMF);
	text->AddChild (rDPI);
	text->AddChild (dpiV);
	
	cancelFrame.Set (82, 112, 134, 136);
	openFrame.Set (140, 112, 192, 136);
	BButton *cancel = new BButton (cancelFrame, "RSW cancel", lstring (131, "Cancel"), new BMessage ('RScn'));
	BButton *open = new BButton (openFrame, "RSW ok", lstring (136, "OK"), new BMessage ('RSok')); 
	open->MakeDefault (true);
	bg->AddChild (cancel);
	bg->AddChild (open);
	
	fStatus = 0;
}
Beispiel #17
0
// You guessed it: This actually does registration checking.
void setup_alphabuffer ()
{
	char buffer[256];
	BPath p;
	char path[B_FILE_NAME_LENGTH];
	find_directory (B_USER_SETTINGS_DIRECTORY, &p);
	strcpy (path, p.Path());
	strcat (path, "/Becasso/Keyfile");
	FILE *kf = fopen (path, "rb");
	extern int gGlobalAlpha;
	if (!kf)
	{
		fclose (kf);
		// Hmm, there is no keyfile... Perhaps a SV db file then?
		generate_alphabuffer (path);
	}
	else
	{
		if (fread (buffer, 255, 1, kf) != 1)
		{
			(new BAlert ("", lstring (8, "Your Keyfile is damaged"), lstring (136, "OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
			fclose (kf);
			return;
		}
		fclose (kf);
		// Here, demangle the keyfile into the registration info.
		// first, xor using the mask.
		char xAlphaMask[256] = { KEYFILE_MASK };
		int i;
		for (i = 0; i < 255; i++)
			gAlphaBuffer[i] = buffer[i] ^ xAlphaMask[i];
	
		// then, check the checksum
		uint32 sum = 0;
		for (i = 0; i < 252; i++)
			sum += gAlphaBuffer[i];
		char *schar = (char *)(&sum);
#if defined (__POWERPC__)
		if (gAlphaBuffer[252] != schar[3]
		 || gAlphaBuffer[253] != schar[2]
		 || gAlphaBuffer[254] != schar[1]
		 || gAlphaBuffer[255] != schar[0])
#else
		if (gAlphaBuffer[252] != schar[0]
		 || gAlphaBuffer[253] != schar[1]
		 || gAlphaBuffer[254] != schar[2]
		 || gAlphaBuffer[255] != schar[3])
#endif
		{
			fprintf (stderr, "keyfile checksum failure\n");//: %x, %x %x %x %x\n", sum, 
//				gAlphaBuffer[252], gAlphaBuffer[253], gAlphaBuffer[254], gAlphaBuffer[255]);
		 	return;	// checksum failure
		}
		
		// check the magic numbers
		if (gAlphaBuffer[9] != 31
		 || gAlphaBuffer[11] != 42)
		{
			fprintf (stderr, "keyfile magic number failure\n");
			return;
		}
		
		// OK, I believe this is a genuine keyfile.
		// Extract the name from it
		extern char gAlphaMask[128];
		for (i = 0; i < 128; i++)
			gAlphaMask[i] = gAlphaBuffer[2*i];
		gGlobalAlpha = 1;
		
		// Note that the keyfile contains more:  The registered version, kind of registration,
		// and the date of registration.  Who knows whether this will be interesting at one point.
	}
}
Beispiel #18
0
// This is for existing Becasso users upon first launch, to generate
// the keyfile.  Silly check: simply look for the SoftwareValet db file
// (it need only exist, so a user can fake it by simply touching it.  Oh well.)
void generate_alphabuffer (char *alpha)
{
	BPath p;
	char reg = REG_NONE;
#if defined (__POWERPC__)
	reg = REG_PPC;
#else
	char path[B_FILE_NAME_LENGTH];
	find_directory (B_USER_SETTINGS_DIRECTORY, &p);
	strcpy (path, p.Path());
	strcat (path, "/packages/Becasso 1.41.4.db");
	FILE *db = fopen (path, "rb");
	if (db)		// db file exists, so generate the keyfile here.
		reg = REG_HAS_14;
	fclose (db);
#endif

	// Other possibility: Preinstalled Becasso
	if (reg == REG_NONE)
	{
		char path[B_FILE_NAME_LENGTH];
		find_directory (B_USER_SETTINGS_DIRECTORY, &p);
		strcpy (path, p.Path());
		strcat (path, "/Becasso/Preinstalled");
		FILE *db = fopen (path, "rb");
		if (db)		// file exists, so generate the keyfile here.
			reg = REG_PREINST;
		fclose (db);
	}
	// Other possibility: This is a CD installation
	if (reg == REG_NONE)
	{
		bool done = false;
		while (!done)
		{
			FILE *cd = fopen ("/BECASSO/README", "rb");
			if (cd)
			{
				reg = REG_CD;
				done = true;
			}
			fclose (cd);
			if (!done)
			{
				int button = (new BAlert ("Reg", lstring (423, "For registration: please mount the Becasso 2.0 CD-ROM"), lstring (131, "Cancel"), lstring (424, "Done")))->Go();
				if (button == 0)
					done = true;
			}
		}
	}
	if (reg == REG_NONE)
		return;
	
	RegWindow *rw = new RegWindow (BRect (100, 100, 440, 240), lstring (420, "Register Becasso 2.0"), reg);
	int val = rw->Go();
	rw->Lock();
	rw->Quit();
	
	if (val == 0)
		return;
	
	if (reg == REG_PREINST)
	{
		system ("rm -rf /boot/home/config/settings/Becasso/Preinstalled");
	}
	
	extern char gAlphaBuffer[256];
	extern char gAlphaMask[128];
	
	int i;
	for (i = 0; i <= strlen (gAlphaMask); i++)
		gAlphaBuffer[2*i] = gAlphaMask[i];
	for (i = strlen(gAlphaMask) + 1; i < 128; i++)
		gAlphaBuffer[2*i] = rand() & 0xFF;
	time_t tm = time (NULL);
	struct tm *tms = localtime (&tm);
	extern const char *Version;
	int vlen = strlen(Version);
	gAlphaBuffer[1] = vlen;
	gAlphaBuffer[3] = tms->tm_year;
	gAlphaBuffer[5] = tms->tm_mon;
	gAlphaBuffer[7] = tms->tm_mday;
	gAlphaBuffer[9] = 31;
	gAlphaBuffer[11] = 42;
	gAlphaBuffer[13] = reg;
	for (i = 0; i <= vlen; i++)
		gAlphaBuffer[2*i + 15] = Version[i];	
	char filler[] = "Well done, you have cracked the keyfile code!  Please don't pass it on, I need to eat too - Sander";
	for (i = 0; i < strlen(filler); i++)
		gAlphaBuffer[2*i + 2*vlen + 15] = filler[i];
	uint32 sum = 0;
	for (i = 0; i < 252; i++)
		sum += gAlphaBuffer[i];
	char *schar = (char *)(&sum);
	gAlphaBuffer[252] = schar[0];
	gAlphaBuffer[253] = schar[1];
	gAlphaBuffer[254] = schar[2];
	gAlphaBuffer[255] = schar[3];
	char xAlphaMask[256] = { KEYFILE_MASK };
	char wbuffer[256];
	for (i = 0; i < 255; i++)
		wbuffer[i] = gAlphaBuffer[i] ^ xAlphaMask[i];
	
	FILE *kf = fopen (alpha, "wb");
	fwrite (wbuffer, 1, 255, kf);
	fclose (kf);
	extern int gGlobalAlpha;
	gGlobalAlpha = 1;
}