Esempio n. 1
0
JNIEXPORT jint JNICALL Java_io_crossroads_jni_XsErrors_loadErrors(JNIEnv* env,
                                                                  jobject obj)
{
    static struct {
        const char* name;
        int value;
    } E[] = {
        { "ENOMEM", ENOMEM },
        { "EFAULT", EFAULT },
        { "EINVAL", EINVAL },
        { "EMFILE", EMFILE },
        { "EINTR", EINTR },
        { "ENAMETOOLONG", ENAMETOOLONG },
        { "ENODEV", ENODEV },
        { "EAGAIN", EAGAIN },
        { "ETIMEDOUT", ETIMEDOUT },
        // 
        { "ENOTSUP", ENOTSUP },
        { "EPROTONOSUPPORT", EPROTONOSUPPORT },
        { "ENOBUFS", ENOBUFS },
        { "ENETDOWN", ENETDOWN },
        { "EADDRINUSE", EADDRINUSE },
        { "EADDRNOTAVAIL", EADDRNOTAVAIL },
        { "ECONNREFUSED", ECONNREFUSED },
        { "EINPROGRESS", EINPROGRESS },
        { "ENOTSOCK", ENOTSOCK },
        { "EAFNOSUPPORT", EAFNOSUPPORT },
        { "EFSM", EFSM },
        { "ENOCOMPATPROTO", ENOCOMPATPROTO },
        { "ETERM", ETERM },
        { 0, 0 },
    };
    jclass cls;
    jfieldID fid;
    int i;
    int n = 0;
 
    cls = (*env)->GetObjectClass(env, obj);
    XS_ASSERT(cls);
    
    for (i = 0; E[i].name != 0; ++i) {
        fid = (*env)->GetStaticFieldID(env, cls, E[i].name, "I");
        XS_ASSERT(fid);

        (*env)->SetStaticIntField(env, cls, fid, E[i].value);
        ++n;
    }
    
    return n;
}
Esempio n. 2
0
void xsCanvasContext::addCurve(xsBezierCurve *curve)
{
	XS_ASSERT(curve != NULL);

	if (curves == NULL)
		curves = xsArrayListCreate(2);

	xsArrayListAdd(curves, curve);
}
Esempio n. 3
0
void xsCanvasContext::addStatus(xsCanvasAttribute* status)
{
	XS_ASSERT(status != NULL);

	if (statusArchive == NULL)
		statusArchive = xsStackCreate(2);

	xsStackPush(statusArchive, status);
}
Esempio n. 4
0
void xsCanvasContext::addRect(xsRectangle *rect)
{
	XS_ASSERT(rect != NULL);

	if (rects == NULL)
		rects = xsArrayListCreate(2);

	xsArrayListAdd(rects, rect);
}
Esempio n. 5
0
void xsCanvasContext::addArc(xsArc *arc)
{
	XS_ASSERT(arc != NULL);

	if (arcs == NULL)
		arcs = xsArrayListCreate(2);

	xsArrayListAdd(arcs, arc);
}
Esempio n. 6
0
void xsCanvasContext::addLine(xsLine *line)
{
	XS_ASSERT(line != NULL);

	if (currentgraphics != NULL && currentgraphics ->lines != NULL)
	{
		xsArrayListAdd(currentgraphics ->lines, line);
	}
}
Esempio n. 7
0
void xsElementList::add(xsObject *parent, xsObject *sub)
{
	XS_ASSERT(sub != NULL);

	if (items == NULL)
		items = xsArrayListCreate(2);

	xsArrayListAdd(items, sub);
	sub->setParent(parent);
}
Esempio n. 8
0
void xsElementList::adopt(xsObject *parent)
{
	xsIterator iter = NULL;
	xsObject *sub;
	XS_ASSERT(parent != NULL);

	for (;;)
	{
		sub = (xsObject *)xsArrayListIterate(items, &iter);
		if (iter == NULL || sub == NULL)
			break;

		sub->setParent(parent);
	}
}
Esempio n. 9
0
extern "C" void __cxa_pure_virtual()
{
	XS_ERROR("Pure virtual function called.");
	XS_ASSERT(0);
	xsQuit();
}
Esempio n. 10
0
/**
 * Query installed application
 */
int xsLauncher::query(int index, xsAppInfo *appInfo)
{
	XS_ASSERT(appInfo != NULL);

	int cnt = count();
	if (cnt < 0)
	{
		XS_ERROR("Query installed count failed.");
		return XS_EC_ERROR;
	}

	if (index >= cnt)
	{
		XS_ERROR("Query installed application out of index.");
		return XS_EC_ERROR;
	}

	// read name, uri and icon from application list
	xsValue name, uri, icon;
	char path[XS_MAX_PATH];

	xsSnprintf(path, sizeof(path), "%d/name", index);
	if (xsBonReadValueFromRes(_resAppList, path, &name) != XS_EC_OK)
		return XS_EC_ERROR;

	xsSnprintf(path, sizeof(path), "%d/uri", index);
	if (xsBonReadValueFromRes(_resAppList, path, &uri) != XS_EC_OK)
		return XS_EC_ERROR;

	xsSnprintf(path, sizeof(path), "%d/icon", index);
	xsBonReadValueFromRes(_resAppList, path, &icon);	// icon is optional

	// feed to AppInfo
	xsTcsCpyN(appInfo->name, name.data.t, sizeof(appInfo->name) / sizeof(xsTChar));
	xsStrCpyN(appInfo->uri, uri.data.s, sizeof(appInfo->uri) / sizeof(char));

	xsMemSet(&appInfo->icon, 0, sizeof(appInfo->icon));
	appInfo->icon.srcType = XS_AFD_UNKNOWN;
	if (icon.type == XS_VALUE_STRING && icon.data.s != NULL)
	{// extract uri and feed AFD
		xsUri *uri = xsUriParse(icon.data.s);
		if (uri != NULL)
		{
			xsTChar iconName[XS_MAX_PATH];
#ifdef XS_UNICODE
			xsMbsToWcs(iconName, uri->base, XS_MAX_PATH - 1);
#else
			xsStrCpyN(iconName, uri->base, XS_MAX_PATH - 1);
#endif

			switch (uri->schema)
			{
			case XS_URI_RES:
				appInfo->icon.srcType = XS_AFD_RESOURCE;
				appInfo->icon.src.res = xsOpenRes(iconName);
				break;
			case XS_URI_FILE:
				appInfo->icon.srcType = XS_AFD_FILENAME;
				appInfo->icon.src.filename = xsTcsDup(iconName); // free at PAL. it's no problem for Launcher is always link with PAL statically.
				break;
			}
				
			xsUriDestroy(uri);
		}
	}

	xsValueDestroy(&name, XS_FALSE);
	xsValueDestroy(&uri, XS_FALSE);
	xsValueDestroy(&icon, XS_FALSE);

	return XS_EC_OK;
}