List of usage examples for org.apache.commons.net.nntp Article simplifiedSubject
String simplifiedSubject
To view the source code for org.apache.commons.net.nntp Article simplifiedSubject.
Click Source Link
From source file:com.almarsoft.GroundhogReader.lib.ServerManager.java
public Vector<Object> getArticleInfoFromXOVER(long articleNumber, String charset, SQLiteDatabase catchedDB) throws IOException, UsenetReaderException, ServerAuthException { clientConnectIfNot();/*from ww w . j av a2 s .c o m*/ long ddbbId = -1; Vector<Object> ret = null; // Get the article information (shorter than the header; we'll fetch the body and the // body when the user clicks on an article.) Article articleInfo = buildArticleInfoFromXOVER(articleNumber); if (articleInfo != null) { String from = articleInfo.getFrom(); if ((!mBannedThreadsSet.contains(articleInfo.simplifiedSubject())) && (!mBannedTrollsSet.contains(from))) { ddbbId = insertArticleInDB(articleInfo, articleNumber, from, charset, catchedDB); } ret = new Vector<Object>(2); ret.add(ddbbId); ret.add(articleInfo.getArticleId()); } return ret; }
From source file:com.almarsoft.GroundhogReader.MessageListActivity.java
private void markThreadAsReadOrUnread(HeaderItemClass header, boolean setread) { // Proxy stuff String thread_subject = header.getArticle().simplifiedSubject(); String msgId;//from ww w.j av a 2 s .c o m Article article; ArrayList<HeaderItemClass> proxyHeaderItems = mHeaderItemsList; HashSet<String> proxyReadSet = mReadSet; int headerItemsSize = proxyHeaderItems.size(); int proxyNumUnread = mNumUnread; // End proxy stuff for (int i = 0; i < headerItemsSize; i++) { article = proxyHeaderItems.get(i).getArticle(); if (thread_subject.equalsIgnoreCase(article.simplifiedSubject())) { msgId = article.getArticleId(); if (setread) { DBUtils.markAsRead(msgId, getApplicationContext()); if (!proxyReadSet.contains(msgId)) proxyNumUnread--; } else { DBUtils.markAsUnread(msgId, getApplicationContext()); if (proxyReadSet.contains(msgId)) proxyNumUnread++; } } } mNumUnread = proxyNumUnread; mTitleBar.setText(mGroup + ":" + mNumUnread); mReadSet = DBUtils.getReadMessagesSet(mGroup, getApplicationContext()); DBUtils.updateUnreadInGroupsTable(mNumUnread, mGroupID, getApplicationContext()); mMsgList.invalidateViews(); }
From source file:com.almarsoft.GroundhogReader.lib.ServerManager.java
public Vector<Object> getArticleInfoAndHeaderFromHEAD(long serverNumber, String charset, SQLiteDatabase catchedDB, String group) throws IOException, UsenetReaderException, ServerAuthException { clientConnectIfNot();/*from w w w . j a v a 2 s. co m*/ long ddbbId = -1; Vector<Object> ret = null; Reader reader = null; try { reader = (DotTerminatedMessageReader) mClient.retrieveArticleHeader(serverNumber); } catch (IOException e) { connect(); reader = (DotTerminatedMessageReader) mClient.retrieveArticleHeader(serverNumber); } if (reader != null) { Header header = new Header(new ReaderInputStream(reader)); Article article = new Article(); article.setArticleNumber(serverNumber); article.setSubject(header.getField("Subject").getBody().trim()); article.setFrom(header.getField("From").getBody().trim()); article.setDate(header.getField("Date").getBody().trim()); article.setArticleId(header.getField("Message-ID").getBody().trim()); // Take the references Field refsField = header.getField("References"); String refsStr = null; if (refsField != null) refsStr = header.getField("References").getBody().trim(); if (refsStr != null) { String[] refs = refsStr.split(" "); for (String r : refs) { if (r.trim().length() == 0) continue; article.addReference(r.trim()); } } if (article != null) { String from = article.getFrom(); if ((!mBannedThreadsSet.contains(article.simplifiedSubject())) && (!mBannedTrollsSet.contains(from))) { ddbbId = insertArticleInDB(article, serverNumber, from, charset, catchedDB); } } // Meter la cabecera en la BBDD String outputPath = UsenetConstants.EXTERNALSTORAGE + "/" + UsenetConstants.APPNAME + "/offlinecache/groups/" + group + "/header/"; FSUtils.writeStringToDiskFile(header.toString(), outputPath, Long.toString(ddbbId)); DBUtils.setMessageCatched(ddbbId, true, mContext); ret = new Vector<Object>(2); ret.add(ddbbId); ret.add(article.getArticleId()); } return ret; }
From source file:com.almarsoft.GroundhogReader.MessageListActivity.java
private void fillListNonRecursive(Article root, int depth, String replyto) { Stack<MiniHeader> stack = new Stack<MiniHeader>(); boolean markReplies = mPrefs.getBoolean("markReplies", true); boolean finished = false; String clean_subject;//www . j ava 2 s.c om MiniHeader tmpMiniItem; HeaderItemClass ih = null; String[] refsArray; String msgId; ArrayList<HeaderItemClass> nonStarredItems = new ArrayList<HeaderItemClass>(); HashSet<String> bannedTrollsSet = DBUtils.getBannedTrolls(getApplicationContext()); HashSet<String> starredSet = DBUtils.getStarredSubjectsSet(getApplicationContext()); // Proxy for speed HashSet<String> myPostsSetProxy = mMyPostsSet; ArrayList<HeaderItemClass> headerItemsListProxy = new ArrayList<HeaderItemClass>(); int refsArrayLen; while (!finished) { if (root == null) finished = true; root.setReplyTo(replyto); if (!root.isDummy()) { ih = new HeaderItemClass(root, depth); // Don't feed the troll if (!bannedTrollsSet.contains(root.getFrom())) { // Put the replies in red (if configured) if (markReplies) { refsArray = root.getReferences(); refsArrayLen = refsArray.length; msgId = null; if (refsArray != null && refsArrayLen > 0) { msgId = refsArray[refsArrayLen - 1]; } if (msgId != null && myPostsSetProxy != null && myPostsSetProxy.contains(msgId)) ih.myreply = true; else ih.myreply = false; } clean_subject = root.simplifiedSubject(); if (starredSet.contains(clean_subject)) { ih.starred = true; headerItemsListProxy.add(ih); // Starred items first } else { // Nonstarred items will be added to mHeaderItemsList at the end nonStarredItems.add(ih); } } } if (root.next != null) { tmpMiniItem = new MiniHeader(root.next, depth, replyto); stack.push(tmpMiniItem); } if (root.kid != null) { replyto = root.getFrom(); if (!root.isDummy()) ++depth; root = root.kid; } else if (!stack.empty()) { tmpMiniItem = stack.pop(); root = tmpMiniItem.article; depth = tmpMiniItem.depth; replyto = tmpMiniItem.replyto; } else finished = true; } // Now add the non starred items after the starred ones int nonStarredItemsLen = nonStarredItems.size(); for (int i = 0; i < nonStarredItemsLen; i++) { headerItemsListProxy.add(nonStarredItems.get(i)); } mHeaderItemsList = headerItemsListProxy; nonStarredItems = null; }