@Override public HttpUriRequest apply(String dsPrsID, String mmeAuthToken) { String authorization = Headers.basicToken(dsPrsID, mmeAuthToken); HttpPost request = new HttpPost(url); request.setHeader(headers.get(Headers.userAgent)); request.setHeader(headers.get(Headers.xMmeClientInfo)); request.setHeader("Authorization", authorization); return request; }
public DataType getDataType(Message message) { final String dataTypeHeader = Headers.get(message, Headers.DATATYPE); final String typeHeader = Headers.get(message, Headers.TYPE); // we have two possible header sets here // legacy: there is Headers.DATATYPE .Headers.TYPE // contains either the string "mms" or an integer which is the internal type of the sms // current: there IS a Headers.DATATYPE containing a string representation of Headers.DataType // Headers.TYPE then contains the type of the sms, mms or calllog entry // The current header set was introduced in version 1.2.00 if (dataTypeHeader == null) { return MmsConsts.LEGACY_HEADER.equalsIgnoreCase(typeHeader) ? DataType.MMS : DataType.SMS; } else { try { return DataType.valueOf(dataTypeHeader.toUpperCase(Locale.ENGLISH)); } catch (IllegalArgumentException e) { return DataType.SMS; // whateva } } }
public Set<Cookie> getCookies() { if (cookies == null) { String header = headers.get(HttpHeaderNames.COOKIE); if (header == null || header.length() == 0) { cookies = Collections.emptySet(); } else { cookies = ServerCookieDecoder.STRICT.decode(header); } } return cookies; }
private void readHeaders() throws IOException { sendCommand("top " + String.valueOf(number) + " 0"); String currentName = null; String currentValue = ""; for (String s = readLine(); s != null && !s.equals("."); s = readLine()) { if (!s.trim().equals("")) { if (Character.isWhitespace(s.charAt(0)) || s.indexOf(':') <= 0) { currentValue += "\n" + s; } else { if (currentName != null) { headers.set(currentName, currentValue); } currentName = s.substring(0, s.indexOf(':')).trim(); currentValue = s.substring(s.indexOf(':') + 1).trim(); } } } if (currentName != null) { headers.set(currentName, currentValue); } if (headers.get("X-UIDL").length == 0) { StringTokenizer tokenizer = new StringTokenizer(sendCommand("uidl " + String.valueOf(number)), " "); if (tokenizer.countTokens() == 3) { tokenizer.nextToken(); tokenizer.nextToken(); headers.set("X-UIDL", tokenizer.nextToken()); } } }
@Override public MediaType getContentType() { return DefaultMediaType.get(headers.get(HttpHeaderNames.CONTENT_TYPE)); }
public boolean isAjaxRequest() { return HttpHeaderConstants.XML_HTTP_REQUEST.equalsIgnoreCase( headers.get(HttpHeaderConstants.X_REQUESTED_WITH)); }
public String header(String name, String defaultValue) { String result = headers.get(name); return result != null ? result : defaultValue; }
public ContentValues messageToContentValues(final Message message) throws IOException, MessagingException { if (message == null) throw new MessagingException("message is null"); final ContentValues values = new ContentValues(); switch (getDataType(message)) { case SMS: if (message.getBody() == null) throw new MessagingException("body is null"); InputStream is = message.getBody().getInputStream(); if (is == null) { throw new MessagingException("body.getInputStream() is null for " + message.getBody()); } final String body = IOUtils.toString(is); final String address = Headers.get(message, Headers.ADDRESS); values.put(SmsConsts.BODY, body); values.put(SmsConsts.ADDRESS, address); values.put(SmsConsts.TYPE, Headers.get(message, Headers.TYPE)); values.put(SmsConsts.PROTOCOL, Headers.get(message, Headers.PROTOCOL)); values.put(SmsConsts.SERVICE_CENTER, Headers.get(message, Headers.SERVICE_CENTER)); values.put(SmsConsts.DATE, Headers.get(message, Headers.DATE)); values.put(SmsConsts.STATUS, Headers.get(message, Headers.STATUS)); values.put(SmsConsts.THREAD_ID, threadHelper.getThreadId(mContext, address)); values.put(SmsConsts.READ, mMarkAsReadOnRestore ? "1" : Headers.get(message, Headers.READ)); break; case CALLLOG: values.put(CallLog.Calls.NUMBER, Headers.get(message, Headers.ADDRESS)); values.put(CallLog.Calls.TYPE, Integer.valueOf(Headers.get(message, Headers.TYPE))); values.put(CallLog.Calls.DATE, Headers.get(message, Headers.DATE)); values.put(CallLog.Calls.DURATION, Long.valueOf(Headers.get(message, Headers.DURATION))); values.put(CallLog.Calls.NEW, 0); PersonRecord record = mPersonLookup.lookupPerson(Headers.get(message, Headers.ADDRESS)); if (!record.isUnknown()) { values.put(CallLog.Calls.CACHED_NAME, record.getName()); values.put(CallLog.Calls.CACHED_NUMBER_TYPE, -2); } break; default: throw new MessagingException("don't know how to restore " + getDataType(message)); } return values; }