Browse Source

Jupiter now in working state. Version changed to 0.9-rc1.

release/0.19
JustinAJ 11 years ago
parent
commit
53212446ad
  1. 114
      Jupiter/IRC_Client.cpp
  2. 2
      Jupiter/Jupiter.h
  3. BIN
      Release/Jupiter.lib

114
Jupiter/IRC_Client.cpp

@ -717,7 +717,7 @@ int Jupiter::IRC::Client::primaryHandler()
} }
if (!sasl) if (!sasl)
{ {
Jupiter::IRC::Client::data_->sock->send("CAP END" ENDL); Jupiter::IRC::Client::data_->sock->send(STRING_LITERAL_AS_REFERENCE("CAP END" ENDL));
Jupiter::IRC::Client::data_->registerClient(); Jupiter::IRC::Client::data_->registerClient();
} }
} }
@ -853,29 +853,29 @@ int Jupiter::IRC::Client::primaryHandler()
case IRC_RPL_LUSERCLIENT: // 251 case IRC_RPL_LUSERCLIENT: // 251
{ {
Jupiter::CStringL key = "RawData."; Jupiter::CStringL key = "RawData.";
unsigned int offset; size_t offset;
unsigned int i = 1; unsigned int i = 1;
do while (true)
{ {
offset = key.aformat("%u", i); offset = key.aformat("%u", i);
const Jupiter::ReadableString &tVal = Jupiter::IRC::Client::readConfigValue(key); const Jupiter::ReadableString &value = Jupiter::IRC::Client::readConfigValue(key);
if (tVal.size() == 0) break; if (value.isEmpty()) break;
key -= offset; key.truncate(offset);
Jupiter::IRC::Client::send(tVal); Jupiter::IRC::Client::send(value);
i++; i++;
} while (1); }
key = "Channel."; key = "Channel.";
i = 1; i = 1;
do while (true)
{ {
offset = key.aformat("%u", i); offset = key.aformat("%u", i);
const Jupiter::ReadableString &tVal = Jupiter::IRC::Client::readConfigValue(key); const Jupiter::ReadableString &tVal = Jupiter::IRC::Client::readConfigValue(key);
if (tVal.size() == 0) break; if (tVal.isEmpty()) break;
key -= offset; key.truncate(offset);
Jupiter::IRC::Client::joinChannel(tVal); Jupiter::IRC::Client::joinChannel(tVal);
i++; i++;
} while (1); }
Jupiter::IRC::Client::data_->connectionStatus = 5; Jupiter::IRC::Client::data_->connectionStatus = 5;
Jupiter::IRC::Client::data_->reconnectAttempts = 0; Jupiter::IRC::Client::data_->reconnectAttempts = 0;
@ -1002,8 +1002,10 @@ int Jupiter::IRC::Client::primaryHandler()
channel->data_->isAddingNames = true; channel->data_->isAddingNames = true;
if (channel->getType() < 0) if (channel->getType() < 0)
{ {
if (Jupiter::IRC::Client::data_->autoPartMessage.size() != 0) Jupiter::IRC::Client::partChannel(chan, Jupiter::IRC::Client::data_->autoPartMessage); if (Jupiter::IRC::Client::data_->autoPartMessage.size() != 0)
else Jupiter::IRC::Client::partChannel(chan); Jupiter::IRC::Client::partChannel(chan, Jupiter::IRC::Client::data_->autoPartMessage);
else
Jupiter::IRC::Client::partChannel(chan);
} }
} }
else if (i >= 0) Jupiter::IRC::Client::data_->channels.get(i)->addUser(Jupiter::IRC::Client::data_->findUserOrAdd(nick)); else if (i >= 0) Jupiter::IRC::Client::data_->channels.get(i)->addUser(Jupiter::IRC::Client::data_->findUserOrAdd(nick));
@ -1381,25 +1383,14 @@ Jupiter::IRC::Client::User *Jupiter::IRC::Client::Data::findUser(const Jupiter::
Jupiter::IRC::Client::User *Jupiter::IRC::Client::Data::findUserOrAdd(const Jupiter::ReadableString &name) Jupiter::IRC::Client::User *Jupiter::IRC::Client::Data::findUserOrAdd(const Jupiter::ReadableString &name)
{ {
unsigned int wc = name.wordCount("!@"); Jupiter::ReferenceString nick = Jupiter::ReferenceString::getWord(name, 0, "!");
Jupiter::ReferenceString nick = (wc == 1) ? (name) : Jupiter::ReferenceString::getWord(name, 0, "!@");
Jupiter::IRC::Client::User *r = Jupiter::IRC::Client::Data::findUser(nick); Jupiter::IRC::Client::User *r = Jupiter::IRC::Client::Data::findUser(nick);
if (r == nullptr) if (r == nullptr)
{ {
r = new Jupiter::IRC::Client::User(); r = new Jupiter::IRC::Client::User();
switch (wc) r->data_->nickname = nick;
{ r->data_->username = Jupiter::ReferenceString::getWord(name, 1, "!@");
case 3: r->data_->hostname = Jupiter::ReferenceString::getWord(name, 2, "!@");
r->data_->hostname = Jupiter::ReferenceString::getWord(name, 2, "!@");
case 2: // This shouldn't EVER happen.
r->data_->username = Jupiter::ReferenceString::getWord(name, 1, "!@");
case 1: // No user/host is in the string.
r->data_->nickname = nick;
break;
default:
fprintf(stderr, "ERROR: Failed to parse name mask: %.*s" ENDL, name.size(), name.ptr());
break;
}
Jupiter::IRC::Client::Data::users.add(r); Jupiter::IRC::Client::Data::users.add(r);
} }
return r; return r;
@ -1496,48 +1487,45 @@ size_t Jupiter::IRC::Client::User::getChannelCount() const
Jupiter::IRC::Client::Channel::Channel(const Jupiter::ReadableString &channelName, Jupiter::IRC::Client *iFace) Jupiter::IRC::Client::Channel::Channel(const Jupiter::ReadableString &channelName, Jupiter::IRC::Client *iFace)
{ {
Jupiter::IRC::Client::Channel::data_ = new Jupiter::IRC::Client::Channel::Data(); Jupiter::IRC::Client::Channel::data_ = new Jupiter::IRC::Client::Channel::Data();
unsigned int i = 0; Jupiter::IRC::Client::Channel::data_->channel = channelName;
const Jupiter::ReadableString *ptr = nullptr; Jupiter::IRC::Client::Channel::data_->serverPrefixSetPtr = iFace->getPrefixes();
Jupiter::ReferenceString section = iFace->getConfigSection();
Jupiter::String key = "Channel."; Jupiter::String key = "Channel.";
size_t offset = key.aformat("%.*s.Type", channelName.size(), channelName.ptr());
iFace->readConfigValue(key);
Jupiter::ReferenceString value = iFace->readConfigValue(key);
if (value.size() != 0)
{
Jupiter::IRC::Client::Channel::data_->type = value.asInt();
return;
}
size_t offset = 0;
// TODO: Make this more efficient -- consider moving responsibility elsewhere. // TODO: Make this more efficient -- consider moving responsibility elsewhere.
while (1) for (unsigned int i = 1;; i++)
{ {
i++; key.truncate(offset);
offset = key.aformat("%u", i); offset = key.aformat("%u", i);
ptr = &Jupiter::IRC::Client::Config->get(iFace->getConfigSection(), Jupiter::ReferenceString(key)); value.set(iFace->readConfigValue(key));
if (ptr->size() == 0)
{ if (value.size() == 0) // No more channels in the list.
if (section != iFace->getConfigSection()) break; break;
i = 0;
section = STRING_LITERAL_AS_REFERENCE("Default"); if (value.getWord(0, WHITESPACE).equalsi(channelName)) // This is our channel.
key.truncate(offset);
continue;
}
if (Jupiter::ReferenceString::getWord(*ptr, 0, WHITESPACE).equalsi(channelName))
{ {
offset += key.aformat(".Type", i); offset += key.concat(".Type");
ptr = &Jupiter::IRC::Client::Config->get(iFace->getConfigSection(), Jupiter::ReferenceString(key)); value.set(iFace->readConfigValue(key));
if (ptr->size() != 0) if (value.size() != 0)
{ Jupiter::IRC::Client::Channel::data_->type = value.asInt();
Jupiter::IRC::Client::Channel::data_->type = ptr->asInt(); else if (iFace->getDefaultChanType() < 0)
key.truncate(offset); Jupiter::IRC::Client::Channel::data_->type = 0;
break; else
} Jupiter::IRC::Client::Channel::data_->type = iFace->getDefaultChanType();
return;
} }
key.truncate(offset);
}
if (ptr->size() == 0)
{
key.aformat("%.*s.Type", channelName.size(), channelName.ptr());
Jupiter::CStringS val = iFace->readConfigValue(key);
if (val.size() != 0) Jupiter::IRC::Client::Channel::data_->type = val.asInt();
else Jupiter::IRC::Client::Channel::data_->type = iFace->getDefaultChanType();
} }
Jupiter::IRC::Client::Channel::data_->channel = channelName;
Jupiter::IRC::Client::Channel::data_->serverPrefixSetPtr = iFace->getPrefixes(); Jupiter::IRC::Client::Channel::data_->type = iFace->getDefaultChanType();
} }
Jupiter::IRC::Client::Channel::~Channel() Jupiter::IRC::Client::Channel::~Channel()

2
Jupiter/Jupiter.h

@ -35,7 +35,7 @@
#define JUPITER_API #define JUPITER_API
#endif // _WIN32 #endif // _WIN32
#define JUPITER_VERSION "Jupiter 0.9" /** Version of this program at compile time. */ #define JUPITER_VERSION "Jupiter 0.9-rc1" /** Version of this program at compile time. */
#if defined __cplusplus #if defined __cplusplus
extern "C" extern "C"

BIN
Release/Jupiter.lib

Binary file not shown.
Loading…
Cancel
Save