aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar CodaFi <devteam.codafi@gmail.com>2014-08-16 12:11:02 -0600
committerGravatar CodaFi <devteam.codafi@gmail.com>2014-08-16 12:11:02 -0600
commit4958054e3cd65fe734e94d64d0ca1b8f8a36fe76 (patch)
tree3ea329a6b05c13400b96130f538a196e037c311f /src
parenta55de9f78bfdc1e93fdf98b55d61669c867232b0 (diff)
Tests
Diffstat (limited to 'src')
-rw-r--r--src/async/nntp/MCNNTPAsyncSession.cc4
-rw-r--r--src/async/nntp/MCNNTPAsyncSession.h6
-rw-r--r--src/async/nntp/MCNNTPFetchArticlesOperation.h4
-rw-r--r--src/core/MCCore.h1
-rw-r--r--src/core/nntp/MCNNTP.h2
-rw-r--r--src/core/nntp/MCNNTPArticleInfo.cc (renamed from src/core/nntp/MCNNTPMessageInfo.cc)34
-rw-r--r--src/core/nntp/MCNNTPArticleInfo.h (renamed from src/core/nntp/MCNNTPMessageInfo.h)12
-rw-r--r--src/core/nntp/MCNNTPSession.cc70
-rw-r--r--src/core/nntp/MCNNTPSession.h8
-rw-r--r--src/objc/nntp/MCONNTP.h2
-rw-r--r--src/objc/nntp/MCONNTPArticleInfo.h (renamed from src/objc/nntp/MCONNTPMessageInfo.h)8
-rw-r--r--src/objc/nntp/MCONNTPArticleInfo.mm (renamed from src/objc/nntp/MCONNTPMessageInfo.mm)16
-rw-r--r--src/objc/nntp/MCONNTPFetchArticlesOperation.h4
-rw-r--r--src/objc/nntp/MCONNTPSession.h2
14 files changed, 87 insertions, 86 deletions
diff --git a/src/async/nntp/MCNNTPAsyncSession.cc b/src/async/nntp/MCNNTPAsyncSession.cc
index 84b5f318..fec7b31b 100644
--- a/src/async/nntp/MCNNTPAsyncSession.cc
+++ b/src/async/nntp/MCNNTPAsyncSession.cc
@@ -172,7 +172,7 @@ NNTPFetchHeaderOperation * NNTPAsyncSession::fetchHeaderOperation(String * group
return op;
}
-NNTPFetchHeaderOperation * NNTPAsyncSession::fetchHeaderOperation(String * groupName, NNTPMessageInfo * msg)
+NNTPFetchHeaderOperation * NNTPAsyncSession::fetchHeaderOperation(String * groupName, NNTPArticleInfo * msg)
{
return fetchHeaderOperation(groupName, msg->index());
}
@@ -187,7 +187,7 @@ NNTPFetchArticleOperation * NNTPAsyncSession::fetchArticleOperation(String * gro
return op;
}
-NNTPFetchArticleOperation * NNTPAsyncSession::fetchArticleOperation(String *groupName, NNTPMessageInfo * msg)
+NNTPFetchArticleOperation * NNTPAsyncSession::fetchArticleOperation(String *groupName, NNTPArticleInfo * msg)
{
return fetchArticleOperation(groupName, msg->index());
}
diff --git a/src/async/nntp/MCNNTPAsyncSession.h b/src/async/nntp/MCNNTPAsyncSession.h
index 501985bc..90557326 100644
--- a/src/async/nntp/MCNNTPAsyncSession.h
+++ b/src/async/nntp/MCNNTPAsyncSession.h
@@ -9,7 +9,7 @@
namespace mailcore {
class NNTPOperation;
- class NNTPMessageInfo;
+ class NNTPArticleInfo;
class NNTPSession;
class NNTPFetchHeaderOperation;
class NNTPFetchArticleOperation;
@@ -55,10 +55,10 @@ namespace mailcore {
virtual MCNNTPFetchArticlesOperation * fetchArticlesOperation(String * group);
virtual NNTPFetchHeaderOperation * fetchHeaderOperation(String * groupName, unsigned int index);
- virtual NNTPFetchHeaderOperation * fetchHeaderOperation(String * groupName, NNTPMessageInfo * msg);
+ virtual NNTPFetchHeaderOperation * fetchHeaderOperation(String * groupName, NNTPArticleInfo * msg);
virtual NNTPFetchArticleOperation * fetchArticleOperation(String *groupName, unsigned int index);
- virtual NNTPFetchArticleOperation * fetchArticleOperation(String *groupName, NNTPMessageInfo * msg);
+ virtual NNTPFetchArticleOperation * fetchArticleOperation(String *groupName, NNTPArticleInfo * msg);
virtual NNTPListNewsgroupsOperation * listAllNewsgroupsOperation();
virtual NNTPListNewsgroupsOperation * listSubscribedNewsgroupsOperation();
diff --git a/src/async/nntp/MCNNTPFetchArticlesOperation.h b/src/async/nntp/MCNNTPFetchArticlesOperation.h
index 9fe6fd1b..28f326ab 100644
--- a/src/async/nntp/MCNNTPFetchArticlesOperation.h
+++ b/src/async/nntp/MCNNTPFetchArticlesOperation.h
@@ -24,14 +24,14 @@ namespace mailcore {
virtual void setGroupName(String * groupName);
virtual String * groupName();
- virtual Array * /* NNTPMessageInfo */ messages();
+ virtual Array * /* NNTPArticleInfo */ messages();
public: // subclass behavior
virtual void main();
private:
String * mGroupName;
- Array * /* NNTPMessageInfo */ mMessages;
+ Array * /* NNTPArticleInfo */ mMessages;
};
}
diff --git a/src/core/MCCore.h b/src/core/MCCore.h
index 74c16147..323bb606 100644
--- a/src/core/MCCore.h
+++ b/src/core/MCCore.h
@@ -14,6 +14,7 @@
#include <MailCore/MCBaseTypes.h>
#include <MailCore/MCIMAP.h>
#include <MailCore/MCPOP.h>
+#include <MailCore/MCNNTP.h>
#include <MailCore/MCRFC822.h>
#include <MailCore/MCSMTP.h>
#include <MailCore/MCRenderer.h>
diff --git a/src/core/nntp/MCNNTP.h b/src/core/nntp/MCNNTP.h
index beec18bb..dd18a961 100644
--- a/src/core/nntp/MCNNTP.h
+++ b/src/core/nntp/MCNNTP.h
@@ -3,7 +3,7 @@
#define MAILCORE_MCNNTP_H
#include <MailCore/MCNNTPGroupInfo.h>
-#include <MailCore/MCNNTPMessageInfo.h>
+#include <MailCore/MCNNTPArticleInfo.h>
#include <MailCore/MCNNTPProgressCallback.h>
#include <MailCore/MCNNTPSession.h>
diff --git a/src/core/nntp/MCNNTPMessageInfo.cc b/src/core/nntp/MCNNTPArticleInfo.cc
index 474de9b3..e3f05998 100644
--- a/src/core/nntp/MCNNTPMessageInfo.cc
+++ b/src/core/nntp/MCNNTPArticleInfo.cc
@@ -1,23 +1,29 @@
//
-// MCNNTPMessageInfo.cpp
+// MCNNTPArticleInfo.cpp
// mailcore2
//
// Created by Robert Widmann on 3/6/14.
// Copyright (c) 2014 MailCore. All rights reserved.
//
-#include "MCNNTPMessageInfo.h"
+#include "MCNNTPArticleInfo.h"
using namespace mailcore;
-void NNTPMessageInfo::init()
+
+void NNTPArticleInfo::init()
{
mIndex = 0;
mSize = 0;
mUid = NULL;
}
-NNTPMessageInfo::NNTPMessageInfo(NNTPMessageInfo * other)
+NNTPArticleInfo::NNTPArticleInfo()
+{
+ init();
+}
+
+NNTPArticleInfo::NNTPArticleInfo(NNTPArticleInfo * other)
{
init();
mIndex = other->mIndex;
@@ -25,48 +31,48 @@ NNTPMessageInfo::NNTPMessageInfo(NNTPMessageInfo * other)
MC_SAFE_REPLACE_COPY(String, mUid, other->mUid);
}
-NNTPMessageInfo::~NNTPMessageInfo()
+NNTPArticleInfo::~NNTPArticleInfo()
{
MC_SAFE_RELEASE(mUid);
}
-String * NNTPMessageInfo::description()
+String * NNTPArticleInfo::description()
{
return String::stringWithUTF8Format("<%s:%p %u %s %u>",
MCUTF8(className()), this, mIndex, MCUTF8(mUid), mSize);
}
-Object * NNTPMessageInfo::copy()
+Object * NNTPArticleInfo::copy()
{
- return new NNTPMessageInfo(this);
+ return new NNTPArticleInfo(this);
}
-void NNTPMessageInfo::setIndex(unsigned int index)
+void NNTPArticleInfo::setIndex(unsigned int index)
{
mIndex = index;
}
-unsigned int NNTPMessageInfo::index()
+unsigned int NNTPArticleInfo::index()
{
return mIndex;
}
-void NNTPMessageInfo::setSize(unsigned int size)
+void NNTPArticleInfo::setSize(unsigned int size)
{
mSize = size;
}
-unsigned int NNTPMessageInfo::size()
+unsigned int NNTPArticleInfo::size()
{
return mSize;
}
-void NNTPMessageInfo::setUid(String * uid)
+void NNTPArticleInfo::setUid(String * uid)
{
MC_SAFE_REPLACE_COPY(String, mUid, uid);
}
-String * NNTPMessageInfo::uid()
+String * NNTPArticleInfo::uid()
{
return mUid;
}
diff --git a/src/core/nntp/MCNNTPMessageInfo.h b/src/core/nntp/MCNNTPArticleInfo.h
index 8522dd0b..7fa90e19 100644
--- a/src/core/nntp/MCNNTPMessageInfo.h
+++ b/src/core/nntp/MCNNTPArticleInfo.h
@@ -1,6 +1,6 @@
-#ifndef MAILCORE_MCNNTPMESSAGEINFO_H
+#ifndef MAILCORE_MCNNTPARTICLEINFO_H
-#define MAILCORE_MCNNTPMESSAGEINFO_H
+#define MAILCORE_MCNNTPARTICLEINFO_H
#include <MailCore/MCBaseTypes.h>
@@ -8,10 +8,10 @@
namespace mailcore {
- class NNTPMessageInfo : public Object {
+ class NNTPArticleInfo : public Object {
public:
- NNTPMessageInfo();
- virtual ~NNTPMessageInfo();
+ NNTPArticleInfo();
+ virtual ~NNTPArticleInfo();
virtual void setIndex(unsigned int index);
virtual unsigned int index();
@@ -23,7 +23,7 @@ namespace mailcore {
virtual String * uid();
public: // subclass behavior
- NNTPMessageInfo(NNTPMessageInfo * other);
+ NNTPArticleInfo(NNTPArticleInfo * other);
virtual String * description();
virtual Object * copy();
diff --git a/src/core/nntp/MCNNTPSession.cc b/src/core/nntp/MCNNTPSession.cc
index a31abb1d..d8cf2632 100644
--- a/src/core/nntp/MCNNTPSession.cc
+++ b/src/core/nntp/MCNNTPSession.cc
@@ -11,7 +11,7 @@
#include <string.h>
#include <libetpan/libetpan.h>
-#include "MCNNTPMessageInfo.h"
+#include "MCNNTPArticleInfo.h"
#include "MCNNTPGroupInfo.h"
#include "MCMessageHeader.h"
#include "MCConnectionLoggerUtils.h"
@@ -175,8 +175,9 @@ void NNTPSession::unsetup()
void NNTPSession::loginIfNeeded(ErrorCode * pError)
{
connectIfNeeded(pError);
- if (* pError != ErrorNone)
+ if (* pError != ErrorNone) {
return;
+ }
if (mState == STATE_CONNECTED) {
login(pError);
@@ -203,38 +204,30 @@ void NNTPSession::readerIfNeeded(ErrorCode * pError)
void NNTPSession::login(ErrorCode * pError)
{
int r;
- const char * utf8username;
- const char * utf8password;
-
- utf8username = MCUTF8(username());
- utf8password = MCUTF8(password());
- if (utf8username == NULL) {
- utf8username = "";
- }
- if (utf8password == NULL) {
- utf8password = "";
- }
-
- r = newsnntp_authinfo_username(mNNTP, utf8username);
- if (r == NEWSNNTP_ERROR_STREAM) {
- * pError = ErrorConnection;
- return;
- }
- else if (r != NEWSNNTP_NO_ERROR) {
- * pError = ErrorAuthentication;
- return;
- }
-
- r = newsnntp_authinfo_password(mNNTP, utf8password);
- if (r == NEWSNNTP_ERROR_STREAM) {
- * pError = ErrorConnection;
- return;
+
+ if (mUsername != NULL) {
+ r = newsnntp_authinfo_username(mNNTP, mUsername->UTF8Characters());
+ if (r == NEWSNNTP_ERROR_STREAM) {
+ * pError = ErrorConnection;
+ return;
+ }
+ else if (r != NEWSNNTP_NO_ERROR) {
+ * pError = ErrorAuthentication;
+ return;
+ }
}
- else if (r != NEWSNNTP_NO_ERROR) {
- * pError = ErrorAuthentication;
- return;
+ if (mPassword != NULL) {
+ r = newsnntp_authinfo_password(mNNTP, mPassword->UTF8Characters());
+ if (r == NEWSNNTP_ERROR_STREAM) {
+ * pError = ErrorConnection;
+ return;
+ }
+ else if (r != NEWSNNTP_NO_ERROR) {
+ * pError = ErrorAuthentication;
+ return;
+ }
}
-
+
mState = STATE_LOGGEDIN;
* pError = ErrorNone;
}
@@ -388,7 +381,8 @@ Array * NNTPSession::listSubscribedNewsgroups(ErrorCode * pError)
grp_info = (struct newsnntp_group_info *) clist_content(iter);
- name = String::stringWithUTF8Characters(grp_info->grp_name);
+ name = String::stringWithUTF8Characters(strdup(grp_info->grp_name));
+ name->retain();
NNTPGroupInfo * info = new NNTPGroupInfo();
info->setName(name);
@@ -437,7 +431,7 @@ MessageHeader * NNTPSession::fetchHeader(String *groupName, unsigned int index,
return result;
}
-MessageHeader * NNTPSession::fetchHeader(String *groupName, NNTPMessageInfo * msg, ErrorCode * pError)
+MessageHeader * NNTPSession::fetchHeader(String *groupName, NNTPArticleInfo * msg, ErrorCode * pError)
{
return fetchHeader(groupName, msg->index(), pError);
}
@@ -478,7 +472,7 @@ Data * NNTPSession::fetchArticle(String *groupName, unsigned int index, NNTPProg
return result;
}
-Data * NNTPSession::fetchArticle(String *groupName, NNTPMessageInfo * msg, NNTPProgressCallback * callback, ErrorCode * pError)
+Data * NNTPSession::fetchArticle(String *groupName, NNTPArticleInfo * msg, NNTPProgressCallback * callback, ErrorCode * pError)
{
return fetchArticle(groupName, msg->index(), callback, pError);
}
@@ -494,11 +488,11 @@ Array * NNTPSession::fetchArticles(String * groupName, ErrorCode * pError)
}
r = newsnntp_listgroup(mNNTP, groupName->UTF8Characters(), &msg_list);
- if (r == MAILPOP3_ERROR_STREAM) {
+ if (r == NEWSNNTP_ERROR_STREAM) {
* pError = ErrorConnection;
return NULL;
}
- else if (r != MAILPOP3_NO_ERROR) {
+ else if (r != NEWSNNTP_NO_ERROR) {
* pError = ErrorFetchMessageList;
return NULL;
}
@@ -513,7 +507,7 @@ Array * NNTPSession::fetchArticles(String * groupName, ErrorCode * pError)
continue;
}
- NNTPMessageInfo * info = new NNTPMessageInfo();
+ NNTPArticleInfo * info = new NNTPArticleInfo();
info->setIndex(*msg_info);
result->addObject(info);
info->release();
diff --git a/src/core/nntp/MCNNTPSession.h b/src/core/nntp/MCNNTPSession.h
index d166354c..bdeb3bc1 100644
--- a/src/core/nntp/MCNNTPSession.h
+++ b/src/core/nntp/MCNNTPSession.h
@@ -8,7 +8,7 @@
namespace mailcore {
- class NNTPMessageInfo;
+ class NNTPArticleInfo;
class NNTPProgressCallback;
class MessageHeader;
@@ -49,12 +49,12 @@ namespace mailcore {
virtual Array * listSubscribedNewsgroups(ErrorCode * pError);
virtual MessageHeader * fetchHeader(String *groupName, unsigned int index, ErrorCode * pError);
- virtual MessageHeader * fetchHeader(String *groupName, NNTPMessageInfo * msg, ErrorCode * pError);
+ virtual MessageHeader * fetchHeader(String *groupName, NNTPArticleInfo * msg, ErrorCode * pError);
- virtual Array * /* NNTPMessageInfo */ fetchArticles(String * groupname, ErrorCode * pError);
+ virtual Array * /* NNTPArticleInfo */ fetchArticles(String * groupname, ErrorCode * pError);
Data * fetchArticle(String *groupName, unsigned int index, NNTPProgressCallback * callback, ErrorCode * pError);
- Data * fetchArticle(String *groupName, NNTPMessageInfo * msg, NNTPProgressCallback * callback, ErrorCode * pError);
+ Data * fetchArticle(String *groupName, NNTPArticleInfo * msg, NNTPProgressCallback * callback, ErrorCode * pError);
virtual void setConnectionLogger(ConnectionLogger * logger);
virtual ConnectionLogger * connectionLogger();
diff --git a/src/objc/nntp/MCONNTP.h b/src/objc/nntp/MCONNTP.h
index 20eb035b..a1328166 100644
--- a/src/objc/nntp/MCONNTP.h
+++ b/src/objc/nntp/MCONNTP.h
@@ -16,7 +16,7 @@
#include <MailCore/MCONNTPFetchArticleOperation.h>
#include <MailCore/MCONNTPFetchArticlesOperation.h>
#include <MailCore/MCONNTPListNewsgroupsOperation.h>
-#include <MailCore/MCONNTPMessageInfo.h>
+#include <MailCore/MCONNTPArticleInfo.h>
#include <MailCore/MCONNTPGroupInfo.h>
#endif
diff --git a/src/objc/nntp/MCONNTPMessageInfo.h b/src/objc/nntp/MCONNTPArticleInfo.h
index d4f06b04..5e2a6887 100644
--- a/src/objc/nntp/MCONNTPMessageInfo.h
+++ b/src/objc/nntp/MCONNTPArticleInfo.h
@@ -1,20 +1,20 @@
//
-// MCONNTPMessageInfo.h
+// MCONNTPArticleInfo.h
// mailcore2
//
// Created by Robert Widmann on 8/13/14.
// Copyright (c) 2014 MailCore. All rights reserved.
//
-#ifndef MAILCORE_MCONNTPMESSAGEINFO_H
+#ifndef MAILCORE_MCONNTPARTICLEINFO_H
-#define MAILCORE_MCONNTPMESSAGEINFO_H
+#define MAILCORE_MCONNTPARTICLEINFO_H
#import <Foundation/Foundation.h>
/** This is information of a message fetched by MCONNTPFetchArticlesOperation.*/
-@interface MCONNTPMessageInfo : NSObject <NSCopying>
+@interface MCONNTPArticleInfo : NSObject <NSCopying>
/** This is the index of a given message.*/
@property (nonatomic, assign) unsigned int index;
diff --git a/src/objc/nntp/MCONNTPMessageInfo.mm b/src/objc/nntp/MCONNTPArticleInfo.mm
index f69267ab..61f226f8 100644
--- a/src/objc/nntp/MCONNTPMessageInfo.mm
+++ b/src/objc/nntp/MCONNTPArticleInfo.mm
@@ -1,23 +1,23 @@
//
-// MCONNTPMessageInfo.m
+// MCONNTPArticleInfo.m
// mailcore2
//
// Created by Robert Widmann on 8/13/14.
// Copyright (c) 2014 MailCore. All rights reserved.
//
-#import "MCONNTPMessageInfo.h"
+#import "MCONNTPArticleInfo.h"
#include "MCAsyncNNTP.h"
#include "MCNNTP.h"
#import "MCOUtils.h"
-@implementation MCONNTPMessageInfo {
- mailcore::NNTPMessageInfo * _nativeInfo;
+@implementation MCONNTPArticleInfo {
+ mailcore::NNTPArticleInfo * _nativeInfo;
}
-#define nativeType mailcore::NNTPMessageInfo
+#define nativeType mailcore::NNTPArticleInfo
+ (void) load
{
@@ -34,8 +34,8 @@
+ (NSObject *) mco_objectWithMCObject:(mailcore::Object *)object
{
- mailcore::NNTPMessageInfo * folder = (mailcore::NNTPMessageInfo *) object;
- return [[[self alloc] initWithMCNNTPMessageInfo:folder] autorelease];
+ mailcore::NNTPArticleInfo * folder = (mailcore::NNTPArticleInfo *) object;
+ return [[[self alloc] initWithMCNNTPArticleInfo:folder] autorelease];
}
- (mailcore::Object *) mco_mcObject
@@ -48,7 +48,7 @@
return MCO_OBJC_BRIDGE_GET(description);
}
-- (id) initWithMCNNTPMessageInfo:(mailcore::NNTPMessageInfo *)info
+- (id) initWithMCNNTPArticleInfo:(mailcore::NNTPArticleInfo *)info
{
self = [super init];
diff --git a/src/objc/nntp/MCONNTPFetchArticlesOperation.h b/src/objc/nntp/MCONNTPFetchArticlesOperation.h
index bd28d99d..6d2a9dab 100644
--- a/src/objc/nntp/MCONNTPFetchArticlesOperation.h
+++ b/src/objc/nntp/MCONNTPFetchArticlesOperation.h
@@ -22,12 +22,12 @@
@param completionBlock Called when the operation is finished.
- - On success `error` will be nil and `messages` will be an array of MCONNTPMessageInfo
+ - On success `error` will be nil and `messages` will be an array of MCONNTPArticleInfo
- On failure, `error` will be set with `MCOErrorDomain` as domain and an
error code available in MCOConstants.h, `messages` will be null
*/
-- (void) start:(void (^)(NSError * error, NSArray * /* MCONNTPMessageInfo */ messages))completionBlock;
+- (void) start:(void (^)(NSError * error, NSArray * /* MCONNTPArticleInfo */ messages))completionBlock;
@end
diff --git a/src/objc/nntp/MCONNTPSession.h b/src/objc/nntp/MCONNTPSession.h
index 6d6ea26f..89795087 100644
--- a/src/objc/nntp/MCONNTPSession.h
+++ b/src/objc/nntp/MCONNTPSession.h
@@ -70,7 +70,7 @@
MCONNTPFetchArticlesOperation * op = [session fetchMessagesOperation];
[op start:^(NSError * error, NSArray * messages) {
- // messages is an array of MCONNTPMessageInfo
+ // messages is an array of MCONNTPArticleInfo
// [info index] can be used as reference for a given message in the other operations.
}];
*/