OperationRequestParameters Peer::opCreateRoomImplementation(const JString& gameID, bool isVisible, bool isOpen, nByte maxPlayers, const Hashtable& customRoomProperties, const Hashtable& customLocalPlayerProperties, const JVector<JString>& propsListedInLobby) { OperationRequestParameters op; if(gameID.length()) op.put(ParameterCode::ROOM_NAME, ValueObject<JString>(gameID)); Hashtable roomProps(Utils::stripToCustomProperties(customRoomProperties)); if(!isOpen) roomProps.put(Properties::Room::IS_OPEN, isOpen); if(!isVisible) roomProps.put(Properties::Room::IS_VISIBLE, isVisible); if(maxPlayers) roomProps.put(Properties::Room::MAX_PLAYERS, maxPlayers); JString* propsListedInLobbyArr = allocateArray<JString>(propsListedInLobby.getSize()); for(unsigned int i=0; i<propsListedInLobby.getSize(); ++i) propsListedInLobbyArr[i] = propsListedInLobby[i]; roomProps.put(Properties::Room::PROPS_LISTED_IN_LOBBY, propsListedInLobbyArr, propsListedInLobby.getSize()); deallocateArray(propsListedInLobbyArr); op.put(ParameterCode::ROOM_PROPERTIES, ValueObject<Hashtable>(roomProps)); Hashtable playerProperties = Utils::stripToCustomProperties(customLocalPlayerProperties); if(playerProperties.getSize()) op.put(ParameterCode::PLAYER_PROPERTIES, ValueObject<Hashtable>(playerProperties)); op.put(ParameterCode::BROADCAST, ValueObject<bool>(true)); op.put(ParameterCode::CLEANUP_CACHE_ON_LEAVE, ValueObject<bool>(true)); return op; }
void JAbout::paint(JGraphics g) { JCanvas::paint(g); int delta = 20; JRect rect(0, 0, width, height); g.draw3DJRect(rect.shrink(delta, delta), -depth); JString text = getText(); if (text.length()) { JFontMetrics fm(g); int dx, dy; JColor c[14] = { JColor::red, JColor::white, JColor::magenta.darker(), JColor::yellow, JColor::orange, JColor::blue, JColor::pink, JColor::magenta, JColor::orange, JColor::green.darker(), JColor::blue, JColor::magenta.darker(), JColor::blue, JColor::yellow }; dy = (height-fm.getHeight())/2; dx = (width-fm.stringWidth(text))/2; g.setJColor(getBackground().brighter()); g.drawJString(text, dx+1, dy+1); g.setJColor(getBackground().darker()); g.drawJString(text, dx-1, dy-1); for (int i=0; i<14; i++) { JString ch = text(i, i+1); g.setJColor(c[i]); g.drawJString(ch, dx, dy); dx += fm.stringWidth(ch); } } }
void MatroskaShellExt_SetRegistryValueStr(TCHAR *value_key, JString the_value) { TCHAR *reg_key = _T("SOFTWARE\\MatroskaProp\\"); HKEY key_handle = NULL; DWORD lpType = NULL; DWORD state = 0; SECURITY_ATTRIBUTES sa = {sizeof(sa), 0,1}; RegCreateKeyEx(HKEY_LOCAL_MACHINE, reg_key, 0, _T(""), 0, KEY_WRITE, &sa, &key_handle, &state); DWORD size = (the_value.length()+1)*sizeof(TCHAR); RegSetValueEx(key_handle, value_key, 0, REG_SZ, (CONST BYTE*)the_value.t_str(), size); //char *err_key = new char[1024]; //FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, temp, 0, err_key, 1024, NULL); RegCloseKey(key_handle); };
void removeDir(JFile dir) { int attr = JFile::LA_DIRECTORY | JFile::LA_SORT; JArray fa = dir.list(attr, "*.*"); if (*(JString*)fa[0] == dotdot) fa.del(0); int i, sz = fa.size(); for (i=0; i<sz; i++) { JString fn = *(JString*)fa[i]; JFile tf = JFile(dir, fn(1, fn.length()-1)); removeDir(tf); } attr = JFile::LA_FILE | JFile::LA_SORT; fa = dir.list(attr, "*.*"); sz = fa.size(); for (i=0; i<sz; i++) { JFile tf = JFile(dir, *(JString*)fa[i]); printf("Delete File %s\n", (char*)tf.getPath()); tf.remove(); } printf("Remove Directory %s\n", (char*)dir.getPath()); dir.removeDir(); }
bool Peer::opAuthenticate(const JString& appID, const JString& appVersion, bool encrypted, const JString& userID, const AuthenticationValues& authenticationValues) { OperationRequestParameters op; op.put(ParameterCode::APPLICATION_ID, ValueObject<JString>(appID)); op.put(ParameterCode::APP_VERSION, ValueObject<JString>(appVersion)); if(userID.length()) op.put(ParameterCode::USER_ID, ValueObject<JString>(userID)); if(authenticationValues.getType() != CustomAuthenticationType::NONE) { op.put(ParameterCode::CLIENT_AUTHENTICATION_TYPE, ValueObject<nByte>(authenticationValues.getType())); if(authenticationValues.getSecret().length()) op.put(ParameterCode::SECRET, ValueObject<JString>(authenticationValues.getSecret())); else { if(authenticationValues.getParameters().length()) op.put(ParameterCode::CLIENT_AUTHENTICATION_PARAMETERS, ValueObject<JString>(authenticationValues.getParameters())); if(authenticationValues.getData().getSize()) op.put(ParameterCode::CLIENT_AUTHENTICATION_DATA, ValueObject<const nByte*>(authenticationValues.getData().getCArray(), static_cast<int>(authenticationValues.getData().getSize()))); } } EGLOG(DebugLevel::INFO, OperationRequest(OperationCode::AUTHENTICATE, op).toString(true)); return opCustom(OperationRequest(OperationCode::AUTHENTICATE, op), true, 0, encrypted); }
void JBasicPermission::init(JString name){ jint len = name.length(); if (len == 0) { throw new JIllegalArgumentException("name can't be empty"); } jchar last = (jchar)name.charAt(len - 1); if (last == '*' && (len == 1 || name.charAt(len - 2) == '.')) { wildcard = true; if (len == 1) { path = ""; } else { path = name.substring(0, len - 1); } } else { if (name=="exitVM") { wildcard = true; path = "exitVM."; exitVM = true; } else { path = name; } } }
bool Peer::opJoinRoom(const JString& gameID, const Hashtable& customLocalPlayerProperties) { return gameID.length() ? opCustom(OperationRequest(OperationCode::JOIN_ROOM, opJoinRoomImplementation(gameID, customLocalPlayerProperties)), true) : false; }
void JWriter::write(JString str){ write(str,0,str.length()); }