private static void drawEvents( SvgFile svg, List<UserData> users, String overrideStroke, Map<Integer, Zone> zones) { float strokeWidth = 0.5f; int ci = 0; for (UserData user : users) { ci = ci + 1 % colors.length; String stroke = overrideStroke != null ? overrideStroke : colors[ci]; for (Event e : user.getEvents()) { // e.get if (e.getGpsTagId() != 0) { Zone z = zones.get(e.getGpsTagId()); if (z != null) { String fill = getZoneFill(z); float rx = (float) ((Math.random() - 0.5) * JITTER); float ry = (float) ((Math.random() - 0.5) * JITTER); svg.circle( rx + scaleX(Mercator.mercX(z.getLon())), ry + scaleY(Mercator.mercY(z.getLat())), scaleD(z.getRadius()), stroke, 1.0f, fill, "fill-opacity=\"0.1\""); } } } } }
private static void drawEventsHod(SvgFile svg, List<UserData> users, Map<Integer, Zone> zones) { float strokeWidth = 0.5f; int ci = 0; for (UserData user : users) { for (Event e : user.getEvents()) { // e.get Float hod = e.getHourOfDay(); if (hod == null) continue; String stroke = getColour(scaleHod(hod)); if (e.getGpsTagId() != 0) { Zone z = zones.get(e.getGpsTagId()); if (z != null) { String fill = getZoneFill(z); float rx = (float) ((Math.random() - 0.5) * JITTER); float ry = (float) ((Math.random() - 0.5) * JITTER); float size = scaleD(z.getRadius()); if (size < 1) size = 1; svg.circle( rx + scaleX(Mercator.mercX(z.getLon())), ry + scaleY(Mercator.mercY(z.getLat())), size, stroke, 1.0f, fill, "fill-opacity=\"0.1\""); } } } } }
/** Prepares player information collected from the database */ private void sql_setupUser() { userID = user.getUserID(); name = user.getUserName(); // check if registered String query = "SELECT fnEnabled, fcIP, fnMID FROM tblDuel2__player WHERE fnUserID = " + userID + " LIMIT 1"; ResultSet rs = null; try { rs = ba.SQLQuery(db, query); if (rs.next()) { registered = true; if (rs.getInt("fnEnabled") == 1) enabled = true; userIP = rs.getString("fcIP"); userMID = rs.getInt("fnMID"); } ba.SQLClose(rs); query = "SELECT fnActive FROM tblDuel2__ban WHERE fnUserID = " + userID + " AND fnActive = 1"; rs = ba.SQLQuery(db, query); if (rs.next()) banned = true; } catch (SQLException e) { bot.debug("[sql_setupUser] Exception when checking if registered: " + name); e.printStackTrace(); } finally { ba.SQLClose(rs); } }
@Test public void testGetID() throws SQLException { int id = UserData.getId("lulz"); assertTrue(id == -1); id = UserData.getId(""); assertTrue(id == -1); }
/** colour by hour of day */ private static void drawPositionsHod(SvgFile svg, List<UserData> users, boolean showPoints) { float strokeWidth = 0.5f; for (UserData user : users) { Position lp = null; Position lastGoodp = null; for (Position p : user.getPositions()) { String stroke = getColour(scaleHod(p.getHourOfDay())); if (lp != null && !lp.isTruncated() && !p.isTruncated()) { svg.line( scaleX(lp.getX()), scaleY(lp.getY()), scaleX(p.getX()), scaleY(p.getY()), stroke, strokeWidth); } else if (lastGoodp != null && !p.isTruncated()) { svg.line( scaleX(lastGoodp.getX()), scaleY(lastGoodp.getY()), scaleX(p.getX()), scaleY(p.getY()), stroke, strokeWidth, "stroke-dasharray=\"" + MAG * 3 + " " + MAG * 3 + "\""); lastGoodp = null; } lp = p; if (!p.isTruncated()) lastGoodp = p; if (showPoints) svg.circle(scaleX(p.getX()), scaleY(p.getY()), 3, stroke, 0.4f, null); } } }
@Override protected String doInBackground(String... params) { // Preparo la richiesta Post ArrayList<NameValuePair> postParams = new ArrayList<NameValuePair>(); postParams.add(new BasicNameValuePair("date", UserData.getInstance().getDate())); postParams.add( new BasicNameValuePair( "cu", UserData.getInstance() .getCU() .substring(0, UserData.getInstance().getCU().length() - 2))); postParams.add( new BasicNameValuePair( "reprint", UserData.getInstance() .getCU() .substring(UserData.getInstance().getCU().length() - 1))); postParams.add(new BasicNameValuePair("search", params[0])); postParams.add(new BasicNameValuePair("imei", params[1])); String res = null; String response = null; try { Log.e("date", UserData.getInstance().getDate()); Log.e( "cu", UserData.getInstance() .getCU() .substring(0, UserData.getInstance().getCU().length() - 2)); Log.e( "reprint", UserData.getInstance().getCU().substring(UserData.getInstance().getCU().length() - 1)); Log.e("search", params[0]); Log.e("imei", params[1]); response = CustomHttpClient.executeHttpPostString(URL_IDENT, postParams); res = response.toString(); res = res.replaceAll("\\s+", ""); Log.e("result", res); // Parso l'oggetto JSON che mi e' tornato JSONObject parsedObject = new JSONObject(res); String nome = parsedObject.getString("nome"); String cognome = parsedObject.getString("cognome"); String datanascita = parsedObject.getString("data"); datumNome.put("title", nome); datumCognome.put("title", cognome); datumDataNascita.put("title", datanascita); Log.e("Found ", nome + " " + cognome + " " + datanascita); } catch (Exception e) { e.printStackTrace(); } return res; }
// Returns user pointed to by cursor. private UserData userFromCursor(Cursor cursor) { UserData user = new UserData(); user.id = cursor.getLong(0); user.sid = cursor.getLong(1); user.name = cursor.getString(2); return user; }
@Override public UserPublicKey getPublicKey(String username) { byte[] dummy = null; UserData user = new UserData(username, dummy); RowData[] users = user.select(); if (users == null || users.length != 1) return null; return new UserPublicKey(users[0].data); }
@Test public void testAuthenticate() throws SQLException { int b = UserData.authenticate("*****@*****.**", ""); assertTrue(b == -1); int c = UserData.authenticate("*****@*****.**", "234234"); assertTrue(c == -1); int d = UserData.authenticate("test@te", "1234"); assertTrue(d == -1); }
public void saveSharedPreferences() { // Se almacena el token del usuario para ver si es necesario // solicitarle que se haga nuevamente log in o no. SharedPreferences prefs = getPreferences(MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putString(USER_EMAIL, UserData.getEmail()); editor.putString(USERNAME, UserData.getUsername()); editor.putString(USER_TOKEN, UserData.getToken()); editor.commit(); }
public synchronized void paint(Graphics g) { if (mLastFrame == null) { return; } int framePosX = 0; int framePosY = 0; VideoFrameRef depthFrame = mLastFrame.getDepthFrame(); if (depthFrame != null) { int width = depthFrame.getWidth(); int height = depthFrame.getHeight(); // make sure we have enough room if (mBufferedImage == null || mBufferedImage.getWidth() != width || mBufferedImage.getHeight() != height) { mBufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); } mBufferedImage.setRGB(0, 0, width, height, mDepthPixels, 0, width); framePosX = (getWidth() - width) / 2; framePosY = (getHeight() - height) / 2; g.drawImage(mBufferedImage, framePosX, framePosY, null); } for (UserData user : mLastFrame.getUsers()) { if (user.getSkeleton().getState() == SkeletonState.TRACKED) { drawLimb(g, framePosX, framePosY, user, JointType.HEAD, JointType.NECK); drawLimb(g, framePosX, framePosY, user, JointType.LEFT_SHOULDER, JointType.LEFT_ELBOW); drawLimb(g, framePosX, framePosY, user, JointType.LEFT_ELBOW, JointType.LEFT_HAND); drawLimb(g, framePosX, framePosY, user, JointType.RIGHT_SHOULDER, JointType.RIGHT_ELBOW); drawLimb(g, framePosX, framePosY, user, JointType.RIGHT_ELBOW, JointType.RIGHT_HAND); drawLimb(g, framePosX, framePosY, user, JointType.LEFT_SHOULDER, JointType.RIGHT_SHOULDER); drawLimb(g, framePosX, framePosY, user, JointType.LEFT_SHOULDER, JointType.TORSO); drawLimb(g, framePosX, framePosY, user, JointType.RIGHT_SHOULDER, JointType.TORSO); drawLimb(g, framePosX, framePosY, user, JointType.LEFT_HIP, JointType.TORSO); drawLimb(g, framePosX, framePosY, user, JointType.RIGHT_HIP, JointType.TORSO); drawLimb(g, framePosX, framePosY, user, JointType.LEFT_HIP, JointType.RIGHT_HIP); drawLimb(g, framePosX, framePosY, user, JointType.LEFT_HIP, JointType.LEFT_KNEE); drawLimb(g, framePosX, framePosY, user, JointType.LEFT_KNEE, JointType.LEFT_FOOT); drawLimb(g, framePosX, framePosY, user, JointType.RIGHT_HIP, JointType.RIGHT_KNEE); drawLimb(g, framePosX, framePosY, user, JointType.RIGHT_KNEE, JointType.RIGHT_FOOT); } } }
public synchronized void paint(Graphics g) { if (mLastFrame == null) { return; } int framePosX = 0; int framePosY = 0; VideoFrameRef depthFrame = mLastFrame.getDepthFrame(); if (depthFrame != null) { int width = depthFrame.getWidth(); int height = depthFrame.getHeight(); // make sure we have enough room if (mBufferedImage == null || mBufferedImage.getWidth() != width || mBufferedImage.getHeight() != height) { mBufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); } mBufferedImage.setRGB(0, 0, width, height, mDepthPixels, 0, width); framePosX = (getWidth() - width) / 2; framePosY = (getHeight() - height) / 2; g.drawImage(mBufferedImage, framePosX, framePosY, null); } for (UserData user : mLastFrame.getUsers()) { if (user.getSkeleton().getState() == SkeletonState.TRACKED) { drawSkeleton(g, framePosX, framePosY, user); // spatial joint's coordinates // giveMeSpatialCoordinateJoints(user); try { createSkeletonInstances(user); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (user.getSkeleton().getState() == SkeletonState.TRACKED && startedTest) { try { createSkeletonInstances(user); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } // System.out.println("send"); } } }
/** Initialise the coordinates for the default body poses (used when we cannot see a user). */ private UserData setUpPose(float[] x, float[] y) { UserData pose = new UserData(-1); for (int i = 0; i < x.length; i++) { float cx = (float) (x[i] * MyWorld.SCALE); float cy = (float) (y[i] * MyWorld.SCALE); pose.setJoint(i, new Joint(i, 1.0f, null, new Point3D(cx, cy, 0.0f))); } return pose; }
public void act() { UserData user = ((MyWorld) getWorld()).getUser(0); if ((user != null) && user.isTracking()) { trackUser(user); } else { // no user visible trackUser(defaultPose); } checkHands(); }
private static void drawTimelineEventsHod( SvgFile svg, List<UserData> members, Map<Integer, Zone> zones) { // TODO Auto-generated method stub for (UserData user : members) { Timeline tl = getTimeline(user); for (Event e : user.getEvents()) { // if (!"newImages".equals(e.getTaskType())) DrawTimelines.drawEvent(svg, e, tl, zones); } } }
/** * @param svg * @param users * @param b */ private static void drawPositions( SvgFile svg, List<UserData> users, String overrideStroke, boolean showPoints) { float strokeWidth = 0.5f; int ci = 0; for (UserData user : users) { ci = ci + 1 % colors.length; String stroke = overrideStroke != null ? overrideStroke : colors[ci]; drawPositions(svg, user, stroke, strokeWidth, showPoints); for (Event e : user.getEvents()) { // e.get } } }
public void InitializeUserData(String command) { // TODO Auto-generated method stub String[] args = Commandline.translateCommandline(command); try { for (int i = 0; i < args.length; i++) { if (args[i].contains("user_id")) { ud.user_id = Integer.parseInt(args[i + 1]); } if (args[i].contains("first_name")) { ud.first_name = args[i + 1]; } if (args[i].contains("last_name")) { ud.last_name = args[i + 1]; } if (args[i].contains("email")) { ud.email = args[i + 1]; } if (args[i].contains("cc_number")) { ud.cc_number = args[i + 1]; } if (args[i].contains("expiration_date")) { ud.expiration_date = new SimpleDateFormat("yyyyMMdd").parse(args[i + 1]); } if (args[i].contains("security_code")) { ud.security_code = Integer.parseInt(args[i + 1]); } if (args[i].contains("phone")) { ud.phone = args[i + 1]; } } } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
@Override protected Boolean doInBackground(Integer... params) { Boolean bool = false; try { UserData.setMemberUsername(context, "gen"); UserData.setSessionId(context, "MTMyODA2NDYwOTM1MDI4NTIxMzU0MjQ2"); String parameter = new String( // "username="******"&" + // "session=" + UserData.getSessionId(context) + "&" + "username="******"gen" + "&" + "session=" + "MTMyODA2NDYwOTM1MDI4NTIxMzU0MjQ2" + "&" + "mode=" + "apply" + "&" + "locationid=" + id); JMCFunction.setDebugLogI(context, "parameter: " + parameter); String json = JMCFunction.getJsonData(context, NearByApi.registerAPI, parameter); JSONObject jsonObject = new JSONObject(json); JSONArray array = jsonObject.optJSONArray("register"); int size = array.length(); for (int i = 0; i < size; i++) { JMCFunction.setDebugLogI( context, array.optJSONObject(i).optString("process") + " " + array.optJSONObject(i).optString("message")); if (array.optJSONObject(i).optString("process").equals(false)) { bool = false; } else { bool = true; } } } catch (JSONException e) { e.printStackTrace(); } return bool; }
public void clearSharedPreferences() { // Se eliminan los datos almacenados pues se requiere un nuevo token. SharedPreferences prefs = getPreferences(MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.clear().commit(); Bundle paramsBag = getIntent().getExtras(); if (paramsBag != null && paramsBag.getInt("actionCode") == CLEAR_USER_DATA) { // Se setean a null los datos del usuario dentro de la clase UserData para simular // un Log out. UserData.setEmail(null); UserData.setUsername(null); UserData.setToken(null); } }
public synchronized void onNewFrame(UserTracker tracker) { if (mLastFrame != null) { mLastFrame.release(); mLastFrame = null; } mLastFrame = mTracker.readFrame(); // check if any new user detected for (UserData user : mLastFrame.getUsers()) { if (user.isNew()) { // start skeleton tracking mTracker.startSkeletonTracking(user.getId()); } } VideoFrameRef depthFrame = mLastFrame.getDepthFrame(); if (depthFrame != null) { ByteBuffer frameData = depthFrame.getData().order(ByteOrder.LITTLE_ENDIAN); ByteBuffer usersFrame = mLastFrame.getUserMap().getPixels().order(ByteOrder.LITTLE_ENDIAN); // make sure we have enough room if (mDepthPixels == null || mDepthPixels.length < depthFrame.getWidth() * depthFrame.getHeight()) { mDepthPixels = new int[depthFrame.getWidth() * depthFrame.getHeight()]; } calcHist(frameData); frameData.rewind(); int pos = 0; while (frameData.remaining() > 0) { short depth = frameData.getShort(); short userId = usersFrame.getShort(); short pixel = (short) mHistogram[depth]; int color = 0xFFFFFFFF; if (userId > 0) { color = mColors[userId % mColors.length]; } mDepthPixels[pos] = color & (0xFF000000 | (pixel << 16) | (pixel << 8) | pixel); pos++; } } repaint(); }
public DuelPlayer(String p, duel2bot bot) { staffer = null; name = p; this.bot = bot; team = null; teams = new int[6]; ba = bot.ba; rules = null; freq = -1; ship = -1; rating = -1; if (ship > 0) status = IN; else status = SPEC; create = false; registered = false; banned = false; enabled = false; userMID = -1; userIP = ""; getRules(); user = new UserData(ba, db, name, true); if (user == null || user.getUserID() < 1) user = null; else sql_setupUser(); }
private static void drawPositions( SvgFile svg, UserData user, String stroke, float strokeWidth, boolean showPoints) { Position lp = null; Position lastGoodp = null; for (Position p : user.getPositions()) { if (lp != null && !lp.isTruncated() && !p.isTruncated()) { svg.line( scaleX(lp.getX()), scaleY(lp.getY()), scaleX(p.getX()), scaleY(p.getY()), stroke, strokeWidth); } else if (lastGoodp != null && !p.isTruncated()) { svg.line( scaleX(lastGoodp.getX()), scaleY(lastGoodp.getY()), scaleX(p.getX()), scaleY(p.getY()), stroke, strokeWidth, "stroke-dasharray=\"" + MAG * 3 + " " + MAG * 3 + "\""); lastGoodp = null; } lp = p; if (!p.isTruncated()) lastGoodp = p; if (showPoints) svg.circle(scaleX(p.getX()), scaleY(p.getY()), 3, stroke, 0.4f, null); } }
public String handCheck() { if (user.getHighestJoint() == Joint.LEFT_HAND) { highJoint = "Left"; return highJoint; } return "boooooom"; }
/** * Outputs time * * @return Human readable time. Will output military time or AM/PM time based on user settings. */ public String getTimeString() { if (UserData.useMilitaryTime()) { return startTime.toString24h() + "-" + endTime.toString24h(); } return startTime.toString12h() + "-" + endTime.toString12h(); }
@Override public boolean addUsername( String username, byte[] encodedUserKey, byte[] signed, byte[] staticData) { UserPublicKey key = new UserPublicKey(encodedUserKey); if (!key.isValidSignature( signed, ArrayOps.concat(username.getBytes(), encodedUserKey, staticData))) return false; UserPublicKey existingKey = getPublicKey(username); if (existingKey != null) return false; String existingUsername = getUsername(key.getPublicKeys()); if (existingUsername.length() > 0) return false; UserData user = new UserData(username, key.getPublicKeys()); return user.insert(); }
@Test public void testUpdate() throws SQLException { UserObject user = new UserObject("*****@*****.**", "12de", "name", 3); user.setId(99); // here is shouldnt work since the user id doesnt exist assertTrue(UserData.updateUser(user) == -1); }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { Cookie[] cookies = request.getCookies(); int userID = -1; boolean newUser = false; // determine whether we've seen this user before if (cookies != null) { for (Cookie c : cookies) { if (c.getName().equals("userID")) { userID = Integer.parseInt(c.getValue()); logger.log(Level.INFO, "Existing user: "******"userID", String.valueOf(userID)); response.addCookie(c); logger.log(Level.INFO, "New user: "******"text/html"); response.setStatus(HttpServletResponse.SC_OK); PrintWriter out = response.getWriter(); String title = "Cookie Servlet"; String bootstrapHeader = "<!DOCTYPE html>" + "<html lang=\"en\">\n" + " <head>\n" + " <title>" + title + "</title>\n" + " <meta charset=\"utf-8\">\n" + " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n" + " <link rel=\"stylesheet\" href=\"http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css\">\n" + " <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js\"></script>\n" + " <script src=\"http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js\"></script>\n" + " </head>\n"; String body = " <body>\n" + " <div class=\"container\">\n" + " <p>Hello, " + (newUser ? "new" : "existing") + " user!</p>\n" + " </div>\n" + " </body>\n"; String footer = "</html>"; String page = bootstrapHeader + body + footer; out.println(page); }
private void doSave() { if (validateFields()) { group.setName(Utils.safeString(nameTextBox.getValue())); group.removeUsers(); for (UserData userData : toUserStore.getModels()) { group.addUser((User) userData.get(Constants.USER)); } final AsyncCallback<Boolean> callbackCheck = new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { WebPasswordSafe.handleServerFailure(caught); } @Override public void onSuccess(Boolean result) { // true => group name already taken, else go ahead and save if (result) { MessageBox.alert(textMessages.error(), textMessages.groupNameAlreadyExists(), null); } else { AsyncCallback<Void> callback = new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { WebPasswordSafe.handleServerFailure(caught); } @Override public void onSuccess(Void result) { Info.display(textMessages.status(), textMessages.groupSaved()); hide(); } }; if (group.getId() == 0) { UserService.Util.getInstance().addGroup(group, callback); } else { UserService.Util.getInstance().updateGroup(group, callback); } } } }; UserService.Util.getInstance().isGroupTaken(group.getName(), group.getId(), callbackCheck); } }
/** Check whether a hand (of any user) touches the radio. Play radio if it does. */ public void checkHands() { MyWorld world = (MyWorld) getWorld(); UserData[] users = world.getTrackedUsers(); for (UserData user : users) { Joint rightHand = user.getJoint(Joint.RIGHT_HAND); Radio radio = getRadio(rightHand.getX(), rightHand.getY()); if (radio != null) { // yes, there was a radio radio.play(1); } else { Joint leftHand = user.getJoint(Joint.LEFT_HAND); radio = getRadio(leftHand.getX(), leftHand.getY()); if (radio != null) { radio.play(2); } } } }
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. if (ViewConfiguration.get(getApplicationContext()).hasPermanentMenuKey()) { if (UserData.getToken() == null) { // El usuario no está loggeado. menu.add(0, R.id.places, Menu.FIRST + 1, getResources().getString(R.string.places)); menu.add(0, R.id.login, Menu.FIRST + 2, getResources().getString(R.string.log_in)); menu.add(0, R.id.aboutUs, Menu.FIRST + 3, getResources().getString(R.string.about_us)); } else { menu.add(0, R.id.places, Menu.FIRST + 1, getResources().getString(R.string.places)); menu.add( 0, R.id.suggestions, Menu.FIRST + 2, getResources().getString(R.string.suggestions)); menu.add(0, R.id.aboutUs, Menu.FIRST + 3, getResources().getString(R.string.about_us)); menu.add(0, R.id.logout, Menu.FIRST + 4, getResources().getString(R.string.log_out)); } } getMenuInflater().inflate(R.menu.map_handler, menu); if (UserData.getToken() == null) { // El usuario no está loggeado. menu.findItem(R.id.places).setVisible(true); menu.findItem(R.id.login).setVisible(true); menu.findItem(R.id.suggestions).setVisible(false); menu.findItem(R.id.aboutUs).setVisible(true); menu.findItem(R.id.logout).setVisible(false); } else { menu.findItem(R.id.places).setVisible(true); menu.findItem(R.id.login).setVisible(false); menu.findItem(R.id.suggestions).setVisible(true); menu.findItem(R.id.aboutUs).setVisible(true); menu.findItem(R.id.logout).setVisible(true); } // Se agrega el SearchWidget. SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.options_menu_main_search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); return true; }