Exemplo n.º 1
0
short bMainThread :: Start()		// Program execution starts here
{
	// attach error handler
	AppErrorHandler defaultHandler("errdemo", CtAll, NULL);
	AddEventHandler(&defaultHandler);

	// Create the application facility
	bFacility *fac = new bFacility(FAC_ERRDEMO, "App", FAC_APPMSGFILE);
	fac->SetHelpFilename(FAC_APPHELPFILE, FAC_APPHELPOFFSET);
	ThisApp->AddFacility(fac);

	// ...and the IO library facility
	fac = new bFacility(FAC_IO, "I/O Library", FAC_IOMSGFILE);
	fac->SetHelpFilename(FAC_IOHELPFILE, FAC_IOHELPOFFSET);
	ThisApp->AddFacility(fac);

	// create help manager
	wHelpManager help("errdemo.hlp");
    help.SetHelpWindowTitle("Help for Error Demo");
   	help.SetHelpTable(MainHelpTable);

	AppWindow w;	    // Contstruct the top level frame window
	Exec();				// Go to the message loop.

	return 0;
}
Exemplo n.º 2
0
bool HttpServer::processRequest(HttpServerConnection &connection, HttpRequest &request, HttpResponse &response)
{
	if (request.isWebSocket())
	{
		bool res = initWebSocket(connection, request, response);
		if (!res) response.badRequest();
	}
	String path = request.getPath();
	if (path.length() > 1 && path.endsWith("/"))
		path = path.substring(0, path.length() - 1);

	if (paths.contains(path))
	{
		paths[path](request, response);
		return true;
	}

	if (defaultHandler)
	{
		debugf("Default server handler for: '%s'", path.c_str());
		defaultHandler(request, response);
		return true;
	}

	debugf("ERROR at server 404: '%s' not found", path.c_str());
	return false;
}
Exemplo n.º 3
0
void ClientUserInputHandler::handleJoin(const BufferInfo &bufferInfo, const QString &text)
{
    if (text.isEmpty()) {
        Client::messageModel()->insertErrorMessage(bufferInfo, tr("/JOIN expects a channel"));
        return;
    }
    switchBuffer(bufferInfo.networkId(), text.section(' ', 0, 0));
    // send to core
    defaultHandler("JOIN", bufferInfo, text);
}
Exemplo n.º 4
0
void ClientUserInputHandler::handleQuery(const BufferInfo &bufferInfo, const QString &text)
{
    if (text.isEmpty()) {
        Client::messageModel()->insertErrorMessage(bufferInfo, tr("/QUERY expects at least a nick"));
        return;
    }
    switchBuffer(bufferInfo.networkId(), text.section(' ', 0, 0));
    // send to core
    defaultHandler("QUERY", bufferInfo, text);
}
Exemplo n.º 5
0
void SerialCommand::onCmdlineComplete(char * marker, char* current) {
#ifdef SERIALCOMMAND_DEBUG
		Serial.println("*******");
		Serial.println("Executing command.");
#endif

	if (currentCommand) {
		currentCommand();
	} else {
#ifdef SERIALCOMMAND_DEBUG
		Serial.println("Executing Default command.");
#endif
		defaultHandler(buffer);
	}
	currentCommand = 0;
	nparam = 0;
}
Exemplo n.º 6
0
void menuLoop()
{
	if (keys == 0)
		keys = keyboardRead();
		
	if (KEY1 && !editMode)	// BACK
	{
		if (menuPage > PAGE_MENU)
			loadPage(PAGE_MENU);
		else if (menuPage == PAGE_MENU)
		{
			configSave();
			loadPage(PAGE_START);
		}			
	}
	
	if (KEYMENU)
		keys = KEY_INIT;
	defaultHandler();
	keys &= KEY_MENU;
}
String RendererDispatcher::FindServiceName(Context &ctx) {
	StartTrace(RendererDispatcher.FindServiceName);
	ROAnything uriPrefixList(ctx.Lookup("URIPrefix2ServiceMap"));
	String requestURI(ctx.Lookup("REQUEST_URI", ""));
	Anything query(ctx.GetQuery());
	SubTraceAny(uriPrefixList, uriPrefixList, "Service Prefixes: ");
	long matchedPrefix = FindURIPrefixInList(requestURI, uriPrefixList);
	if (matchedPrefix >= 0) {
		String service;
		Renderer::RenderOnString(service, ctx, uriPrefixList[matchedPrefix]);
		query["Service"] = service;
		query["URIPrefix"] = uriPrefixList.SlotName(matchedPrefix);
		SubTraceAny(query, query, "Query: ");
		Trace("Service [" << service << "]");
		return service;
	} else if (uriPrefixList.GetSize() > 0) {
		query["Error"] = String("Service[").Append(requestURI.SubString(0, requestURI.StrChr('/', 1))).Append("]NotFound");
	}
	String defaultHandler(ServiceDispatcher::FindServiceName(ctx));
	Trace("Service:<" << defaultHandler << ">");
	return defaultHandler;
}
Exemplo n.º 8
0
static void editModeHandler()
{
	if (KEY4)	// DONE;
	{
		editMode = OFF;
		
		if (editValueType == TYPE_UINT8)
			*(uint8_t*)editValuePtr = editValue;
		else if (editValueType == TYPE_INT8)
			*(int8_t*)editValuePtr = editValue;
		
		//configSave();
		lcdSelectFont(NULL);
		keys = KEY_REFRESH;
		// call defaultHandler to refresh the screen
		defaultHandler();
		return;
	}
	if (ANYKEY)
	{
		if (KEY2)	// DOWN?
		{
			if (editValue > editLoLimit)
				editValue--;
		}
		else if (KEY3)	// UP?
		{
			if (editValue < editHiLimit)
				editValue++;
		}
		else if (KEY1)	// CLR?
			editValue = editInitialValue;
			
		writeValue(2, 34, editValue, 5, -1);
	}
}
Exemplo n.º 9
0
static Bool moverHandler(EVENT evt, long param, int more, CITWINDOW *wnd)
	{
	switch (evt)
		{
		case EVT_DRAWINT:
			{
			if (wnd->flags.visible)
				{
				if (buildClipArray(wnd))
					{
					CitWindowOutStr(wnd, 2, 1, getcwmsg(1), cfg.attr);
					freeClipArray();
					}
				}

			break;
			}

		case EVT_MSTAT:
			{
			if (more & 1)
				{
				SRECT rect = wnd->parent->extents;
				SRECT rect2 = rect;
				int i, h, w;

				h = rect.bottom - rect.top + 1;
				w = rect.right - rect.left + 1;

				i = long_HI(param);

				i = min(i, (scrollpos + 1 - h));
				rect.top = i;
				rect.bottom = rect.top + h - 1;

				i = long_LO(param);

				i = min(i, (conCols - w));
				rect.left = i;
				rect.right = rect.left + w - 1;

				if ((wnd->parent->func)(EVT_CHECKNEWEXT, (long) &rect, 0,
						wnd->parent))
					{
					wnd->parent->extents = rect;

					(wnd->parent->func)(EVT_DRAWALL, 0, 0, wnd->parent);
					redrawRect(rect2);
					}
				}
			else
				{
				destroyCitWindow(wnd, FALSE);
				}

			break;
			}

		case EVT_INKEY:
			{
			if (param == ESC)
				{
				destroyCitWindow(wnd, FALSE);
				}
			else if (param > 256)
				{
				switch (param >> 8)
					{
					case CURS_DOWN:
						{
						if (wnd->parent->extents.bottom < scrollpos)
							{
							SRECT rect = wnd->parent->extents;
							SRECT rect2 = rect;

							rect.top++;
							rect.bottom++;

							if ((wnd->parent->func)(EVT_CHECKNEWEXT,
									(long) &rect, 0, wnd->parent))
								{
								wnd->parent->extents = rect;

								(wnd->parent->func)(EVT_DRAWALL, 0, 0,
										wnd->parent);

								redrawRect(rect2);
								}
							}

						break;
						}

					case CURS_UP:
						{
						if (wnd->parent->extents.top)
							{
							SRECT rect = wnd->parent->extents;
							SRECT rect2 = rect;

							rect.top--;
							rect.bottom--;

							if ((wnd->parent->func)(EVT_CHECKNEWEXT,
									(long) &rect, 0, wnd->parent))
								{
								wnd->parent->extents = rect;

								(wnd->parent->func)(EVT_DRAWALL, 0, 0,
										wnd->parent);

								redrawRect(rect2);
								}
							}

						break;
						}

					case CURS_LEFT:
						{
						if (wnd->parent->extents.left)
							{
							SRECT rect = wnd->parent->extents;
							SRECT rect2 = rect;

							rect.left--;
							rect.right--;

							if ((wnd->parent->func)(EVT_CHECKNEWEXT,
									(long) &rect, 0, wnd->parent))
								{
								wnd->parent->extents = rect;

								(wnd->parent->func)(EVT_DRAWALL, 0, 0,
										wnd->parent);

								redrawRect(rect2);
								}
							}

						break;
						}

					case CURS_RIGHT:
						{
						if (wnd->parent->extents.right < conCols - 1)
							{
							SRECT rect = wnd->parent->extents;
							SRECT rect2 = rect;

							rect.left++;
							rect.right++;

							if ((wnd->parent->func)(EVT_CHECKNEWEXT,
									(long) &rect, 0, wnd->parent))
								{
								wnd->parent->extents = rect;

								(wnd->parent->func)(EVT_DRAWALL, 0, 0,
										wnd->parent);

								redrawRect(rect2);
								}
							}

						break;
						}
					}
				}

			break;
			}

		default:
			{
			return (defaultHandler(evt, param, more, wnd));
			}
		}

	return (TRUE);
	}
Exemplo n.º 10
0
static Bool sizerHandler(EVENT evt, long param, int more, CITWINDOW *wnd)
	{
	switch (evt)
		{
		case EVT_DRAWINT:
			{
			if (wnd->flags.visible)
				{
				if (buildClipArray(wnd))
					{
					CitWindowOutStr(wnd, 2, 1, getcwmsg(2), cfg.attr);
					freeClipArray();
					}
				}

			break;
			}

		case EVT_MSTAT:
			{
			if (more & 1)
				{
				SRECT rect = wnd->parent->extents;
				SRECT rect2 = rect;

				switch (((sizerData *) wnd->LocalData)->c)
					{
					case TOPLEFT:
						{
						int i;

						i = long_HI(param);

						i = min(i, (rect.bottom - 1));
						rect.top = i;

						i = long_LO(param);

						i = min(i, (rect.right - 10));
						rect.left = i;

						break;
						}

					case BOTTOMRIGHT:
						{
						int i;

						i = long_HI(param);

						i = max(i, (rect.top + 1));
						i = min(i, scrollpos);
						rect.bottom = i;

						i = long_LO(param);

						i = max(i, (rect.left + 10));
						rect.right = i;

						break;
						}

					case TOPRIGHT:
						{
						int i;

						i = long_HI(param);

						i = min(i, (rect.bottom - 1));
						rect.top = i;

						i = long_LO(param);

						i = max(i, (rect.left + 10));
						rect.right = i;

						break;
						}

					case BOTTOMLEFT:
						{
						int i;

						i = long_HI(param);

						i = max(i, (rect.top + 1));
						i = min(i, scrollpos);
						rect.bottom = i;

						i = long_LO(param);

						i = min(i, (rect.right - 10));
						rect.left = i;

						break;
						}
					}

				if ((wnd->parent->func)(EVT_CHECKNEWEXT, (long) &rect, 0,
						wnd->parent))
					{
					wnd->parent->extents = rect;

					(wnd->parent->func)(EVT_DRAWALL, 0, 0, wnd->parent);
					redrawRect(rect2);
					}
				}
			else
				{
				destroyCitWindow(wnd, FALSE);
				}

			break;
			}

		case EVT_INKEY:
			{
			if (param == ESC)
				{
				destroyCitWindow(wnd, FALSE);
				}
			else if (param > 256)
				{
				switch (param >> 8)
					{
					case CURS_DOWN:
						{
						if (wnd->parent->extents.bottom < scrollpos)
							{
							SRECT rect = wnd->parent->extents;
							SRECT rect2 = rect;

							rect.bottom++;

							if ((wnd->parent->func)(EVT_CHECKNEWEXT,
									(long) &rect, 0, wnd->parent))
								{
								wnd->parent->extents = rect;

								(wnd->parent->func)(EVT_DRAWALL, 0, 0,
										wnd->parent);

								redrawRect(rect2);
								}
							}

						break;
						}

					case CURS_UP:
						{
						if (wnd->parent->extents.bottom >
								wnd->parent->extents.top + 1)
							{
							SRECT rect = wnd->parent->extents;
							SRECT rect2 = rect;

							rect.bottom--;

							if ((wnd->parent->func)(EVT_CHECKNEWEXT,
									(long) &rect, 0, wnd->parent))
								{
								wnd->parent->extents = rect;

								(wnd->parent->func)(EVT_DRAWALL, 0, 0,
										wnd->parent);

								redrawRect(rect2);
								}
							}

						break;
						}

					case CURS_LEFT:
						{
						if (wnd->parent->extents.right >
								wnd->parent->extents.left + 5)
							{
							SRECT rect = wnd->parent->extents;
							SRECT rect2 = rect;

							rect.right--;

							if ((wnd->parent->func)(EVT_CHECKNEWEXT,
									(long) &rect, 0, wnd->parent))
								{
								wnd->parent->extents = rect;

								(wnd->parent->func)(EVT_DRAWALL, 0, 0,
										wnd->parent);

								redrawRect(rect2);
								}
							}

						break;
						}

					case CURS_RIGHT:
						{
						if (wnd->parent->extents.right < conCols - 1)
							{
							SRECT rect = wnd->parent->extents;
							SRECT rect2 = rect;

							rect.right++;

							if ((wnd->parent->func)(EVT_CHECKNEWEXT,
									(long) &rect, 0, wnd->parent))
								{
								wnd->parent->extents = rect;

								(wnd->parent->func)(EVT_DRAWALL, 0, 0,
										wnd->parent);

								redrawRect(rect2);
								}

							wnd->parent->extents.right++;
							(wnd->parent->func)(EVT_DRAWALL, param, 0, wnd->parent);
							}

						break;
						}
					}
				}

			break;
			}

		default:
			{
			return (defaultHandler(evt, param, more, wnd));
			}
		}

	return (TRUE);
	}