コード例 #1
0
ファイル: CConfig.cpp プロジェクト: svn2github/synergy-plus
void
CConfig::removeScreen(const CString& name)
{
	// get canonical name and find cell
	CString canonical = getCanonicalName(name);
	CCellMap::iterator index = m_map.find(canonical);
	if (index == m_map.end()) {
		return;
	}

	// remove from map
	m_map.erase(index);

	// disconnect
	for (index = m_map.begin(); index != m_map.end(); ++index) {
		CCell& cell = index->second;
		for (UInt32 i = 0; i < kNumDirections; ++i) {
			if (getCanonicalName(cell.m_neighbor[i]) == canonical) {
				cell.m_neighbor[i].erase();
			}
		}
	}

	// remove aliases (and canonical name)
	for (CNameMap::iterator index = m_nameToCanonicalName.begin();
								index != m_nameToCanonicalName.end(); ) {
		if (index->second == canonical) {
			m_nameToCanonicalName.erase(index++);
		}
		else {
			++index;
		}
	}
}
コード例 #2
0
ファイル: CConfig.cpp プロジェクト: svn2github/synergy-plus
bool
CConfig::renameScreen(const CString& oldName,
							const CString& newName)
{
	// get canonical name and find cell
	CString oldCanonical = getCanonicalName(oldName);
	CCellMap::iterator index = m_map.find(oldCanonical);
	if (index == m_map.end()) {
		return false;
	}

	// accept if names are equal but replace with new name to maintain
	// case.  otherwise, the new name must not exist.
	if (!CStringUtil::CaselessCmp::equal(oldName, newName) &&
		m_nameToCanonicalName.find(newName) != m_nameToCanonicalName.end()) {
		return false;
	}

	// update cell
	CCell tmpCell = index->second;
	m_map.erase(index);
	m_map.insert(std::make_pair(newName, tmpCell));

	// update name
	m_nameToCanonicalName.erase(oldCanonical);
	m_nameToCanonicalName.insert(std::make_pair(newName, newName));

	// update connections
	for (index = m_map.begin(); index != m_map.end(); ++index) {
		for (UInt32 i = 0; i < kNumDirections; ++i) {
			if (CStringUtil::CaselessCmp::equal(getCanonicalName(
						index->second.m_neighbor[i]), oldCanonical)) {
				index->second.m_neighbor[i] = newName;
			}
		}
	}

	// update alias targets
	if (CStringUtil::CaselessCmp::equal(oldName, oldCanonical)) {
		for (CNameMap::iterator index = m_nameToCanonicalName.begin();
							index != m_nameToCanonicalName.end(); ++index) {
			if (CStringUtil::CaselessCmp::equal(
							index->second, oldCanonical)) {
				index->second = newName;
			}
		}
	}

	return true;
}
コード例 #3
0
ファイル: CConfig.cpp プロジェクト: svn2github/synergy-plus
CString
CConfig::getNeighbor(const CString& srcName, EDirection srcSide) const
{
	assert(srcSide >= kFirstDirection && srcSide <= kLastDirection);

	// find source cell
	CCellMap::const_iterator index = m_map.find(getCanonicalName(srcName));
	if (index == m_map.end()) {
		return CString();
	}

	// return connection
	return getCanonicalName(index->second.m_neighbor[
								srcSide - kFirstDirection]);
}
コード例 #4
0
ファイル: remote.c プロジェクト: asmecher/neoHessel
void mpg123Play (PlayerStatus *status, ListNode *who) {
        char *theName;
	theName = getCanonicalName(who);
	fprintf (stderr, "Loading %s\n", theName);
        fprintf (status->in, "LOAD %s\n", theName);
	fflush (status->in);
        free (theName);
	setState (status, STATE_PLAYING, 1);
}
コード例 #5
0
ファイル: JavaClass.cpp プロジェクト: whvirgil2015/JniHelpers
jfieldID JavaClass::getField(const char* field_name) const {
    if (!isInitialized()) {
        JavaExceptionUtils::throwExceptionOfType(JavaThreadUtils::getEnvForCurrentThread(),
                kTypeIllegalStateException,
                "Cannot call getField without class info (forgot to merge?)");
        return NULL;
    }

    const std::string key(field_name);
    FieldMap::const_iterator mapFindIter = _fields->find(key);
    if (mapFindIter == _fields->end()) {
        JavaExceptionUtils::throwExceptionOfType(JavaThreadUtils::getEnvForCurrentThread(),
                kTypeIllegalArgumentException,
                "Field '%s' is not cached in class '%s'", field_name, getCanonicalName());
        return NULL;
    }

    return mapFindIter->second;
}
コード例 #6
0
ファイル: CConfig.cpp プロジェクト: svn2github/synergy-plus
bool
CConfig::connect(const CString& srcName,
				EDirection srcSide, const CString& dstName)
{
	assert(srcSide >= kFirstDirection && srcSide <= kLastDirection);

	// find source cell
	CCellMap::iterator index = m_map.find(getCanonicalName(srcName));
	if (index == m_map.end()) {
		return false;
	}

	// connect side (overriding any previous connection).  we
	// canonicalize in getNeighbor() instead of here because the
	// destination name doesn't have to exist yet.
	index->second.m_neighbor[srcSide - kFirstDirection] = dstName;

	return true;
}
コード例 #7
0
ファイル: JavaClass.cpp プロジェクト: whvirgil2015/JniHelpers
void JavaClass::cacheField(JNIEnv *env, const char *field_name, const char *field_type) {
    LOG_DEBUG("Caching field '%s' (type %s) in class '%s'", field_name, field_type, getSimpleName());
    if (!isInitialized()) {
        JavaExceptionUtils::throwExceptionOfType(env, kTypeIllegalStateException,
                "Attempt to call cacheField without having set class info");
        return;
    }

    std::string fieldTypeSignature;
    JavaClassUtils::makeNameForSignature(fieldTypeSignature, field_type);
    jfieldID field = env->GetFieldID(_clazz_global.get(), field_name, fieldTypeSignature.c_str());
    JavaExceptionUtils::checkException(env);
    if (field != NULL) {
        _fields_global[field_name] = field;
    } else {
        JavaExceptionUtils::throwExceptionOfType(env, kTypeJavaClass(NoSuchFieldError),
                "Field '%s' (type '%s') not found on class %s",
                field_name, field_type, getCanonicalName());
    }
}
コード例 #8
0
ファイル: JavaClass.cpp プロジェクト: whvirgil2015/JniHelpers
void JavaClass::cacheMethod(JNIEnv *env, const char* method_name, const char* return_type, ...) {
    LOG_DEBUG("Caching method '%s' in class '%s'", method_name, getSimpleName());
    if (!isInitialized()) {
        JavaExceptionUtils::throwExceptionOfType(env, kTypeIllegalStateException,
                "Attempt to call cacheMethod without having set class info");
        return;
    }

    va_list arguments;
    va_start(arguments, return_type);
    std::string signature;
    JavaClassUtils::makeSignatureWithList(signature, return_type, arguments);
    va_end(arguments);

    jmethodID method = env->GetMethodID(_clazz_global.get(), method_name, signature.c_str());
    JavaExceptionUtils::checkException(env);
    if (method != NULL) {
        _methods_global[method_name] = method;
    } else {
        JavaExceptionUtils::throwExceptionOfType(env, kTypeJavaClass(NoSuchMethodError),
                "Method '%s' (signature: %s) not found on class '%s'",
                method_name, signature.c_str(), getCanonicalName());
    }
}
コード例 #9
0
ファイル: JavaClass.cpp プロジェクト: whvirgil2015/JniHelpers
const char* JavaClass::getSimpleName() const {
    const char* lastSlash = strrchr(getCanonicalName(), '/');
    return lastSlash != NULL ? lastSlash + 1 : getCanonicalName();
}
コード例 #10
0
ファイル: JavaClass.cpp プロジェクト: whvirgil2015/JniHelpers
bool JavaClass::registerNativeMethods(JNIEnv *env) {
    LOG_DEBUG("Registering native methods on class '%s'", getSimpleName());
    if (_jni_methods.empty()) {
        return false;
    }

    if (!isInitialized()) {
        JavaExceptionUtils::throwRuntimeException(env, "Could not find cached class for %s", getCanonicalName());
        return false;
    }

    bool result = (env->RegisterNatives(_clazz_global.get(), &_jni_methods[0], (jint)_jni_methods.size()) < 0);
    _jni_methods.clear();
    return result;
}
コード例 #11
0
ファイル: JavaClass.cpp プロジェクト: whvirgil2015/JniHelpers
void JavaClass::setClass(JNIEnv *env) {
    LOG_INFO("Looking up corresponding Java class for '%s'", getCanonicalName());
    _clazz_global.set(env->FindClass(getCanonicalName()));
    JavaExceptionUtils::checkException(env);
    _clazz = _clazz_global.get();
}
コード例 #12
0
ファイル: CConfig.cpp プロジェクト: svn2github/synergy-plus
bool
CConfig::isCanonicalName(const CString& name) const
{
	return CStringUtil::CaselessCmp::equal(getCanonicalName(name), name);
}