In order for a network and certain channels to be added automatically in a blank core
configuration, add the following to a [NetworkName] block in networks.ini:
Default=Yes
DefaultChannels=#channel1,#channel2,#channel3
We'll create the network(s), and on first connect, the given channels will be joined automatically.
p->attachSlot(SIGNAL(identityCreated(const Identity &)), this, SLOT(coreIdentityCreated(const Identity &)));
p->attachSlot(SIGNAL(identityRemoved(IdentityId)), this, SLOT(coreIdentityRemoved(IdentityId)));
- p->attachSignal(this, SIGNAL(requestCreateNetwork(const NetworkInfo &)), SIGNAL(createNetwork(const NetworkInfo &)));
+ p->attachSignal(this, SIGNAL(requestCreateNetwork(const NetworkInfo &, const QStringList &)), SIGNAL(createNetwork(const NetworkInfo &, const QStringList &)));
p->attachSignal(this, SIGNAL(requestRemoveNetwork(NetworkId)), SIGNAL(removeNetwork(NetworkId)));
p->attachSlot(SIGNAL(networkCreated(NetworkId)), this, SLOT(coreNetworkCreated(NetworkId)));
p->attachSlot(SIGNAL(networkRemoved(NetworkId)), this, SLOT(coreNetworkRemoved(NetworkId)));
else return 0;
}
-void Client::createNetwork(const NetworkInfo &info) {
- emit instance()->requestCreateNetwork(info);
+void Client::createNetwork(const NetworkInfo &info, const QStringList &persistentChannels) {
+ emit instance()->requestCreateNetwork(info, persistentChannels);
}
void Client::removeNetwork(NetworkId id) {
Q_ASSERT(!_bufferViewManager);
_bufferViewManager = new BufferViewManager(signalProxy(), this);
connect(bufferViewManager(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog()));
- connect(bufferViewManager(), SIGNAL(initDone()), this, SLOT(createDefautBufferView()));
+ connect(bufferViewManager(), SIGNAL(initDone()), this, SLOT(createDefaultBufferView()));
createDefaultIdentity();
+ createDefaultNetworks();
_syncedToCore = true;
emit connected();
Client::backlogManager()->requestInitialBacklog();
}
-void Client::createDefautBufferView() {
+void Client::createDefaultBufferView() {
if(bufferViewManager()->bufferViewConfigs().isEmpty()) {
BufferViewConfig config(-1);
config.setBufferViewName(tr("All Buffers"));
}
}
+void Client::createDefaultNetworks() {
+ if(_networks.isEmpty()) {
+ QStringList defaultNets = Network::presetNetworks(true);
+ foreach(QString net, defaultNets) {
+ NetworkInfo info = Network::networkInfoFromPreset(net);
+ if(info.networkName.isEmpty())
+ continue;
+ QStringList defaultChans = Network::presetDefaultChannels(net);
+ createNetwork(info, defaultChans);
+ }
+ }
+}
+
void Client::setSecuredConnection() {
emit securedConnection();
}
*/
static void removeIdentity(IdentityId id);
- static void createNetwork(const NetworkInfo &info);
+ static void createNetwork(const NetworkInfo &info, const QStringList &persistentChannels = QStringList());
static void updateNetwork(const NetworkInfo &info);
static void removeNetwork(NetworkId id);
void networkCreated(NetworkId id);
void networkRemoved(NetworkId id);
- void requestCreateNetwork(const NetworkInfo &info);
+ void requestCreateNetwork(const NetworkInfo &info, const QStringList &persistentChannels = QStringList());
void requestRemoveNetwork(NetworkId);
void newClientSyncer(ClientSyncer *);
void setConnectedToCore(AccountId id, QIODevice *socket = 0);
void setSyncedToCore();
void requestInitialBacklog();
- void createDefautBufferView();
+ void createDefaultBufferView();
void createDefaultIdentity();
+ void createDefaultNetworks();
void setSecuredConnection();
p->attachSignal(this, SIGNAL(networkCreated(NetworkId)));
p->attachSignal(this, SIGNAL(networkRemoved(NetworkId)));
- p->attachSlot(SIGNAL(createNetwork(const NetworkInfo &)), this, SLOT(createNetwork(const NetworkInfo &)));
+ p->attachSlot(SIGNAL(createNetwork(const NetworkInfo &, const QStringList &)), this, SLOT(createNetwork(const NetworkInfo &, const QStringList &)));
p->attachSlot(SIGNAL(removeNetwork(NetworkId)), this, SLOT(removeNetwork(NetworkId)));
loadSettings();
QHash<QString, QString> CoreSession::persistentChannels(NetworkId id) const {
return Core::persistentChannels(user(), id);
- return QHash<QString, QString>();
}
// FIXME switch to BufferId
/*** Network Handling ***/
-void CoreSession::createNetwork(const NetworkInfo &info_) {
+void CoreSession::createNetwork(const NetworkInfo &info_, const QStringList &persistentChans) {
NetworkInfo info = info_;
int id;
_networks[id] = net;
signalProxy()->synchronize(net);
emit networkCreated(id);
+ // create persistent chans
+ foreach(QString channel, persistentChans) {
+ Core::bufferInfo(user(), info.networkId, BufferInfo::ChannelBuffer, channel, true);
+ Core::setChannelPersistent(user(), info.networkId, channel, true);
+ }
} else {
qWarning() << qPrintable(tr("CoreSession::createNetwork(): Trying to create a network that already exists, updating instead!"));
_networks[info.networkId]->requestSetNetworkInfo(info);
//! Create a network and propagate the changes to the clients.
/** \param info The network's settings.
*/
- void createNetwork(const NetworkInfo &info);
+ void createNetwork(const NetworkInfo &info, const QStringList &persistentChannels = QStringList());
//! Remove network and propagate that fact to the clients.
/** \param network The id of the network to be removed.