Huggle  build:^490^dce1e5c
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
mainwindow.cpp
1 //This program is free software: you can redistribute it and/or modify
2 //it under the terms of the GNU General Public License as published by
3 //the Free Software Foundation, either version 3 of the License, or
4 //(at your option) any later version.
5 
6 //This program is distributed in the hope that it will be useful,
7 //but WITHOUT ANY WARRANTY; without even the implied warranty of
8 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 //GNU General Public License for more details.
10 
11 #include "mainwindow.hpp"
12 #include "ui_mainwindow.h"
13 
14 using namespace Huggle;
15 
16 MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
17 {
18  QDateTime load = QDateTime::currentDateTime();
20  {
22  }
23  this->fScoreWord = NULL;
24  this->fSessionData = NULL;
25  this->fReportForm = NULL;
26 #if !PRODUCTION_BUILD
27  this->fBlockForm = NULL;
28  this->fDeleteForm = NULL;
29 #endif
31  this->wlt = NULL;
32  this->fWaiting = NULL;
33  this->EditablePage = false;
34  ShuttingDown = false;
35  ui->setupUi(this);
36  this->wq = NULL;
37  this->Status = new QLabel();
38  ui->statusBar->addWidget(this->Status);
39  this->showMaximized();
40  this->tb = new HuggleTool();
41  this->Queries = new ProcessList(this);
42  this->SystemLog = new HuggleLog(this);
43  this->Browser = new HuggleWeb(this);
44  this->Queue1 = new HuggleQueue(this);
45  this->_History = new History(this);
46  this->wHistory = new HistoryForm(this);
47  this->wUserInfo = new UserinfoForm(this);
48  this->VandalDock = new VandalNw(this);
49  this->addDockWidget(Qt::LeftDockWidgetArea, this->Queue1);
50  this->addDockWidget(Qt::BottomDockWidgetArea, this->SystemLog);
51  this->addDockWidget(Qt::TopDockWidgetArea, this->tb);
52  this->addDockWidget(Qt::BottomDockWidgetArea, this->Queries);
53  this->addDockWidget(Qt::TopDockWidgetArea, this->wHistory);
54  this->addDockWidget(Qt::TopDockWidgetArea, this->wUserInfo);
55  this->addDockWidget(Qt::BottomDockWidgetArea, this->VandalDock);
56  this->preferencesForm = new Preferences(this);
57  this->aboutForm = new AboutForm(this);
58  this->ui->actionBlock_user->setEnabled(Configuration::Rights.contains("block"));
59  this->ui->actionDelete->setEnabled(Configuration::Rights.contains("delete"));
60  this->ui->actionProtect->setEnabled(Configuration::Rights.contains("protect"));
61  this->addDockWidget(Qt::LeftDockWidgetArea, this->_History);
62  this->SystemLog->resize(100, 80);
63  QStringList _log = Core::RingLogToQStringList();
64  int c=0;
65  while (c<_log.count())
66  {
67  SystemLog->InsertText(_log.at(c));
68  c++;
69  }
70  this->CurrentEdit = NULL;
71  this->setWindowTitle("Huggle 3 QT-LX on " + Configuration::Project.Name);
72  ui->verticalLayout->addWidget(this->Browser);
73  this->Ignore = NULL;
74  DisplayWelcomeMessage();
75  // initialise queues
76  if (!Configuration::LocalConfig_UseIrc)
77  {
78  /// \todo LOCALIZE ME
79  Core::Log("Feed: irc is disabled by project config");
80  }
81  if (Configuration::UsingIRC && Configuration::LocalConfig_UseIrc)
82  {
84  ui->actionIRC->setChecked(true);
85  if (!Core::PrimaryFeedProvider->Start())
86  {
87  /// \todo LOCALIZE ME
88  Core::Log("ERROR: primary feed provider has failed, fallback to wiki provider");
90  ui->actionIRC->setChecked(false);
91  ui->actionWiki->setChecked(true);
94  }
95  } else
96  {
97  ui->actionIRC->setChecked(false);
98  ui->actionWiki->setChecked(true);
101  }
102  if (Configuration::LocalConfig_WarningTypes.count() > 0)
103  {
104  this->RevertSummaries = new QMenu(this);
105  this->WarnMenu = new QMenu(this);
106  this->RevertWarn = new QMenu(this);
107  int r=0;
108  while (r<Configuration::LocalConfig_WarningTypes.count())
109  {
110  QAction *action = new QAction(Core::GetValueFromKey(Configuration::LocalConfig_WarningTypes.at(r)), this);
111  QAction *actiona = new QAction(Core::GetValueFromKey(Configuration::LocalConfig_WarningTypes.at(r)), this);
112  QAction *actionb = new QAction(Core::GetValueFromKey(Configuration::LocalConfig_WarningTypes.at(r)), this);
113  this->RevertWarn->addAction(actiona);
114  this->WarnMenu->addAction(actionb);
115  this->RevertSummaries->addAction(action);
116  r++;
117  connect(action, SIGNAL(triggered()), this, SLOT(CustomRevert()));
118  connect(actiona, SIGNAL(triggered()), this, SLOT(CustomRevertWarn()));
119  connect(actionb, SIGNAL(triggered()), this, SLOT(CustomWarn()));
120  }
121  ui->actionWarn->setMenu(this->WarnMenu);
122  ui->actionRevert->setMenu(this->RevertSummaries);
123  ui->actionRevert_and_warn->setMenu(this->RevertWarn);
124  }
125 
126  this->timer1 = new QTimer(this);
127  this->ui->actionTag_2->setVisible(false);
128 #ifdef PRODUCTION
129  this->ui->actionTag->setVisible(false);
130 #endif
131  connect(this->timer1, SIGNAL(timeout()), this, SLOT(on_Tick()));
132  this->timer1->start(200);
133  this->fRemove = NULL;
134  this->eq = NULL;
135  QFile *layout = NULL;
136  if (QFile().exists(Configuration::GetConfigurationPath() + "mainwindow_state"))
137  {
138  Core::DebugLog("Loading state");
139  layout =new QFile(Configuration::GetConfigurationPath() + "mainwindow_state");
140  if (!layout->open(QIODevice::ReadOnly))
141  {
142  /// \todo LOCALIZE ME
143  Core::Log("ERROR: Unable to read state from a config file");
144  } else
145  {
146  if (!this->restoreState(layout->readAll()))
147  {
148  Core::DebugLog("Failed to restore state");
149  }
150  }
151  layout->close();
152  delete layout;
153  }
154  if (QFile().exists(Configuration::GetConfigurationPath() + "mainwindow_geometry"))
155  {
156  Core::DebugLog("Loading geometry");
157  layout = new QFile(Configuration::GetConfigurationPath() + "mainwindow_geometry");
158  if (!layout->open(QIODevice::ReadOnly))
159  {
160  Core::Log("ERROR: Unable to read geometry from a config file");
161  } else
162  {
163  if (!this->restoreGeometry(layout->readAll()))
164  {
165  Core::DebugLog("Failed to restore layout");
166  }
167  }
168  layout->close();
169  delete layout;
170  }
171  if (Configuration::Verbosity == 0)
172  {
173  ui->menuDebug->setVisible(false);
174  }
175  Core::Log("Main form was loaded in " + QString::number(load.secsTo(QDateTime::currentDateTime())) + " whee");
176  this->VandalDock->Connect();
177 }
178 
179 MainWindow::~MainWindow()
180 {
181  delete this->fRemove;
182  delete this->wUserInfo;
183  delete this->wHistory;
184  delete this->wlt;
185  delete this->fWaiting;
186  delete this->VandalDock;
187  delete this->_History;
188  delete this->RevertWarn;
189  delete this->WarnMenu;
190  delete this->RevertSummaries;
191  delete this->Queries;
192  delete this->preferencesForm;
193  delete this->aboutForm;
194  delete this->fSessionData;
195  delete this->fScoreWord;
196  delete this->Ignore;
197  delete this->Queue1;
198  delete this->SystemLog;
199  delete this->Status;
200  delete this->Browser;
201 #if !PRODUCTION_BUILD
202  delete this->fBlockForm;
203  delete this->fDeleteForm;
204 #endif
205  delete this->fUaaReportForm;
206  delete ui;
207  delete this->tb;
208 }
209 
211 {
212  if (!CheckExit())
213  {
214  return;
215  }
216 
218  {
220  return;
221  }
222 
223  if (this->CurrentEdit->User->IsReported)
224  {
225  /// \todo LOCALIZE ME
226  Core::Log("ERROR: This user is already reported");
227  return;
228  }
229 
230  if (!Configuration::LocalConfig_AIV)
231  {
232  QMessageBox mb;
233  /// \todo LOCALIZE ME
234  mb.setText("This project doesn't support AIV system");
235  /// \todo LOCALIZE ME
236  mb.setWindowTitle("Function not available");
237  mb.setIcon(QMessageBox::Information);
238  mb.exec();
239  return;
240  }
241 
242  if (this->CurrentEdit == NULL)
243  {
244  return;
245  }
246 
247  if (this->fReportForm != NULL)
248  {
249  delete this->fReportForm;
250  this->fReportForm = NULL;
251  }
252 
253  this->fReportForm = new ReportUser(this);
254  this->fReportForm->show();
255  this->fReportForm->SetUser(this->CurrentEdit->User);
256 }
257 
258 void MainWindow::ProcessEdit(WikiEdit *e, bool IgnoreHistory)
259 {
260  if (e == NULL || this->ShuttingDown)
261  {
262  return;
263  }
264  // we need to safely delete the edit later
265  e->RegisterConsumer("MainForm");
266  // if there are actually some totaly old edits in history that we need to delete
267  while (this->Historical.count() > Configuration::HistorySize)
268  {
269  WikiEdit *prev = this->Historical.at(0);
270  if (prev == e)
271  {
272  break;
273  }
274  this->Historical.removeAt(0);
275  Core::DeleteEdit(prev);
276  }
277  if (this->Historical.contains(e) == false)
278  {
279  this->Historical.append(e);
280  }
281  if (this->CurrentEdit != NULL)
282  {
283  if (!IgnoreHistory)
284  {
285  if (this->CurrentEdit->Next != NULL)
286  {
287  // now we need to get to last edit in chain
288  WikiEdit *latest = CurrentEdit;
289  while (latest->Next != NULL)
290  {
291  latest = latest->Next;
292  }
293  latest->Next = e;
294  e->Previous = latest;
295  } else
296  {
297  this->CurrentEdit->Next = e;
298  e->Previous = this->CurrentEdit;
299  }
300  }
301  }
302  e->User->Resync();
303  this->EditablePage = true;
304  this->wUserInfo->ChangeUser(e->User);
305  this->wHistory->Update(e);
306  this->CurrentEdit = e;
307  this->Browser->DisplayDiff(e);
308  this->Render();
309 }
310 
312 {
313  if (this->CurrentEdit != NULL)
314  {
315  if (this->CurrentEdit->Page == NULL)
316  {
317  throw new Exception("Page of CurrentEdit can't be NULL at MainWindow::Render()");
318  }
319  this->tb->SetTitle(this->CurrentEdit->Page->PageName);
320  this->tb->SetPage(this->CurrentEdit->Page);
321  this->tb->SetUser(this->CurrentEdit->User->Username);
322  QString word = "";
323  if (this->CurrentEdit->ScoreWords.count() != 0)
324  {
325  word = " words: ";
326  int x = 0;
327  while (x < this->CurrentEdit->ScoreWords.count())
328  {
329  word += this->CurrentEdit->ScoreWords.at(x) + ", ";
330  x++;
331  }
332  if (word.endsWith(", "))
333  {
334  word = word.mid(0, word.length() - 2);
335  }
336  }
337 
338  /// \todo LOCALIZE ME
339  this->tb->SetInfo("Diff of page: " + this->CurrentEdit->Page->PageName
340  + " (score: " + QString::number(this->CurrentEdit->Score)
341  + word + ")");
342  return;
343  }
344  this->tb->SetTitle(this->Browser->CurrentPageName());
345 }
346 
348 {
349  if (!CheckExit() || !CheckEditableBrowserPage())
350  {
351  return;
352  }
354  {
356  return;
357  }
358  if (this->CurrentEdit == NULL)
359  {
360  return;
361  }
362 
363  if (this->fRemove != NULL)
364  {
365  delete this->fRemove;
366  }
367 
368  this->fRemove = new SpeedyForm();
369  this->fRemove->Init(this->CurrentEdit->User, this->CurrentEdit->Page);
370  this->fRemove->show();
371 }
372 
373 void MainWindow::closeEvent(QCloseEvent *event)
374 {
375  if (this->ShuttingDown)
376  {
377  event->ignore();
378  return;
379  }
380  this->Exit();
381  event->ignore();
382 }
383 
384 RevertQuery *MainWindow::Revert(QString summary, bool nd, bool next)
385 {
386  bool rollback = true;
387  if (this->CurrentEdit == NULL)
388  {
389  /// \todo LOCALIZE ME
390  Core::Log("ERROR: Unable to revert, edit is null");
391  return NULL;
392  }
393 
394  if (!this->CurrentEdit->IsPostProcessed())
395  {
396  /// \todo LOCALIZE ME
397  Core::Log("ERROR: This edit is still being processed, please wait");
398  return NULL;
399  }
400 
401  if (this->CurrentEdit->RollbackToken == "")
402  {
403  /// \todo LOCALIZE ME
404  Core::Log("WARNING: Rollback token for edit " + this->CurrentEdit->Page->PageName + " could not be retrieved, fallback to manual edit");
405  rollback = false;
406  }
407 
409  {
410  this->CurrentEdit->User->Resync();
411  this->CurrentEdit->User->setBadnessScore(this->CurrentEdit->User->getBadnessScore(false) - 10);
412  Hooks::OnRevert(this->CurrentEdit);
413  RevertQuery *q = Core::RevertEdit(this->CurrentEdit, summary, false, rollback, nd);
414  if (next)
415  {
416  this->Queue1->Next();
417  }
418  return q;
419  }
420  return NULL;
421 }
422 
423 bool MainWindow::Warn(QString WarningType, RevertQuery *dependency)
424 {
425  if (this->CurrentEdit == NULL)
426  {
427  Core::DebugLog("NULL");
428  return false;
429  }
430 
432  {
434  return false;
435  }
436 
437  // check if user wasn't changed and if was, let's update the info
438  this->CurrentEdit->User->Resync();
439 
440  // get a template
441  this->CurrentEdit->User->WarningLevel++;
442 
443  if (this->CurrentEdit->User->WarningLevel > 4)
444  {
445  if (this->CurrentEdit->User->IsReported)
446  {
447  return false;
448  }
449  if (Core::ReportPreFlightCheck())
450  {
451  this->_ReportUser();
452  }
453  return false;
454  }
455 
456  QString __template = WarningType + QString::number(this->CurrentEdit->User->WarningLevel);
457 
458  QString warning = Core::RetrieveTemplateToWarn(__template);
459 
460  if (warning == "")
461  {
462  /// \todo LOCALIZE ME
463  Core::Log("There is no such warning template " + __template);
464  return false;
465  }
466 
467  warning = warning.replace("$2", this->CurrentEdit->GetFullUrl()).replace("$1", this->CurrentEdit->Page->PageName);
468 
469  QString title = "Message re " + this->CurrentEdit->Page->PageName;
470 
471  switch (this->CurrentEdit->User->WarningLevel)
472  {
473  case 1:
474  title = Configuration::LocalConfig_WarnSummary;
475  break;
476  case 2:
477  title = Configuration::LocalConfig_WarnSummary2;
478  break;
479  case 3:
480  title = Configuration::LocalConfig_WarnSummary3;
481  break;
482  case 4:
483  title = Configuration::LocalConfig_WarnSummary4;
484  break;
485  }
486 
487  title = title.replace("$1", this->CurrentEdit->Page->PageName);
488  /// \todo Properly implement system to ensure that section head is not posted after level 1 warning
489  Core::MessageUser(this->CurrentEdit->User, warning, "Your edits to " + this->CurrentEdit->Page->PageName,
490  title, true, dependency);
491  Hooks::OnWarning(this->CurrentEdit->User);
492 
493  return true;
494 }
495 
496 QString MainWindow::GetSummaryKey(QString item)
497 {
498  if (item.contains(";"))
499  {
500  QString type = item.mid(0, item.indexOf(";"));
501  int c=0;
502  while(c < Configuration::LocalConfig_WarningTypes.count())
503  {
504  QString x = Configuration::LocalConfig_WarningTypes.at(c);
505  if (x.startsWith(type + ";"))
506  {
507  x = Configuration::LocalConfig_WarningTypes.at(c);
508  x = x.mid(x.indexOf(";") + 1);
509  if (x.endsWith(","))
510  {
511  x = x.mid(0, x.length() - 1);
512  }
513  return x;
514  }
515  c++;
516  }
517  }
518  return item;
519 }
520 
521 void MainWindow::on_actionExit_triggered()
522 {
523  Exit();
524 }
525 
526 void MainWindow::DisplayWelcomeMessage()
527 {
529  this->Browser->DisplayPreFormattedPage(welcome);
530  this->EditablePage = false;
531  this->Render();
532 }
533 
534 void MainWindow::on_actionPreferences_triggered()
535 {
536  preferencesForm->show();
537 }
538 
539 void MainWindow::on_actionContents_triggered()
540 {
541  QDesktopServices::openUrl(Configuration::GlobalConfig_DocumentationPath);
542 }
543 
544 void MainWindow::on_actionAbout_triggered()
545 {
546  aboutForm->show();
547 }
548 
549 void MainWindow::on_MainWindow_destroyed()
550 {
551  Core::Shutdown();
552 }
553 
554 void MainWindow::on_Tick()
555 {
556  Core::FinalizeMessages();
557  bool RetrieveEdit = true;
558  GC::DeleteOld();
559  // if there is no working feed, let's try to fix it
560  if (Core::PrimaryFeedProvider->IsWorking() != true && this->ShuttingDown != true)
561  {
562  Core::Log("Failure of primary feed provider, trying to recover");
563  if (!Core::PrimaryFeedProvider->Restart())
564  {
568  }
569  }
570  // check if queue isn't full
571  if (this->Queue1->Items.count() > Configuration::Cache_InfoSize)
572  {
573  if (ui->actionStop_feed->isChecked())
574  {
576  RetrieveEdit = false;
577  } else
578  {
579  this->Queue1->Trim();
580  }
581  } else
582  {
583  if (ui->actionStop_feed->isChecked())
584  {
585  if (Core::PrimaryFeedProvider->IsPaused())
586  {
588  }
589  }
590  }
591  if (RetrieveEdit)
592  {
593  if (Core::PrimaryFeedProvider->ContainsEdit())
594  {
595  // we take the edit and start post processing it
597  if (edit != NULL)
598  {
599  Core::PostProcessEdit(edit);
600  PendingEdits.append(edit);
601  }
602  }
603  }
604  if (PendingEdits.count() > 0)
605  {
606  // postprocessed edits can be added to queue
607  int c = 0;
608  while (c<PendingEdits.count())
609  {
610  if (PendingEdits.at(c)->IsPostProcessed())
611  {
612  this->Queue1->AddItem(PendingEdits.at(c));
613  PendingEdits.removeAt(c);
614  } else
615  {
616  c++;
617  }
618  }
619  }
620  QString t = "All systems go! - currently processing " + QString::number(Core::ProcessingEdits.count())
621  + " edits and " + QString::number(Core::RunningQueriesGetCount()) + " queries."
622  + " I have " + QString::number(Configuration::WhiteList.size())
623  + " whitelisted users and you have "
624  + QString::number(HuggleQueueItemLabel::Count)
625  + " edits waiting in queue.";
626  if (Configuration::Verbosity > 0)
627  {
628  t += " QGC: " + QString::number(GC::list.count())
629  + "U: " + QString::number(WikiUser::ProblematicUsers.count());
630  }
631  this->Status->setText(t);
632  // let's refresh the edits that are being post processed
633  if (Core::ProcessingEdits.count() > 0)
634  {
635  int Edit = 0;
636  while (Edit < Core::ProcessingEdits.count())
637  {
638  if (Core::ProcessingEdits.at(Edit)->FinalizePostProcessing())
639  {
640  WikiEdit *e = Core::ProcessingEdits.at(Edit);
641  Core::ProcessingEdits.removeAt(Edit);
642  e->UnregisterConsumer(HUGGLECONSUMER_CORE_POSTPROCESS);
643  }
644  else
645  {
646  Edit++;
647  }
648  }
649  }
651  this->lUnwrittenLogs.lock();
652  if (this->UnwrittenLogs.count() > 0)
653  {
654  int c = 0;
655  while (c < this->UnwrittenLogs.count())
656  {
657  this->SystemLog->InsertText(this->UnwrittenLogs.at(c));
658  c++;
659  }
660  this->UnwrittenLogs.clear();
661  }
662  this->lUnwrittenLogs.unlock();
663  this->Queries->RemoveExpired();
664 }
665 
666 void MainWindow::on_Tick2()
667 {
668  if (this->Shutdown != ShutdownOpUpdatingConf)
669  {
670  if (this->wq == NULL)
671  {
672  return;
673  }
675  {
677  {
679  return;
680  }
681  if (!this->wq->Processed())
682  {
683  return;
684  }
685  QString list = wq->Result->Data;
686  list = list.replace("<!-- list -->", "");
687  QStringList wl = list.split("|");
688  int c=0;
689  fWaiting->Status(40, "Merging");
690  while (c < wl.count())
691  {
692  if (wl.at(c) != "")
693  {
694  Configuration::WhiteList.append(wl.at(c));
695  }
696  c++;
697  }
698  Configuration::WhiteList.removeDuplicates();
699  this->fWaiting->Status(60, "Updating whitelist");
701  this->wq->UnregisterConsumer(HUGGLECONSUMER_MAINFORM);
702  this->wq = new WLQuery();
703  this->wq->RegisterConsumer(HUGGLECONSUMER_MAINFORM);
704  this->wq->Save = true;
705  this->wq->Process();
706  return;
707  }
709  {
711  {
712  return;
713  }
714  // we finished writing the wl
715  this->wq->UnregisterConsumer(HUGGLECONSUMER_MAINFORM);
716  this->fWaiting->Status(80, "Updating user config");
717  this->wq = NULL;
719  QString page = Configuration::GlobalConfig_UserConf;
720  page = page.replace("$1", Configuration::UserName);
721  WikiPage *uc = new WikiPage(page);
722  this->eq = Core::EditPage(uc, Configuration::MakeLocalUserConfig(), "Writing user config", true);
723  this->eq->RegisterConsumer(HUGGLECONSUMER_MAINFORM);
724  delete uc;
725  return;
726  }
727  } else
728  {
729  // we need to check if config was written
730  if (!this->eq->Processed())
731  {
732  return;
733  }
734  Core::Log(this->eq->Result->Data);
735  this->eq->UnregisterConsumer(HUGGLECONSUMER_MAINFORM);
736  this->eq = NULL;
737  this->wlt->stop();
738  Core::Shutdown();
739  }
740 }
741 
742 void MainWindow::on_actionNext_triggered()
743 {
744  this->Queue1->Next();
745 }
746 
747 void MainWindow::on_actionNext_2_triggered()
748 {
749  this->Queue1->Next();
750 }
751 
752 void MainWindow::on_actionWarn_triggered()
753 {
754  if (!CheckExit() || !CheckEditableBrowserPage())
755  {
756  return;
757  }
759  {
761  return;
762  }
763  this->Warn("warning", NULL);
764 }
765 
766 void MainWindow::on_actionRevert_currently_displayed_edit_triggered()
767 {
768  if (!CheckExit())
769  {
770  return;
771  }
773  {
775  return;
776  }
777 
778  this->Revert();
779 }
780 
781 void MainWindow::on_actionWarn_the_user_triggered()
782 {
783  if (!CheckExit())
784  {
785  return;
786  }
788  {
790  return;
791  }
792  this->Warn("warning", NULL);
793 }
794 
795 void MainWindow::on_actionRevert_currently_displayed_edit_and_warn_the_user_triggered()
796 {
797  if (!CheckExit())
798  {
799  return;
800  }
802  {
804  return;
805  }
806 
807  RevertQuery *result = this->Revert("", true, false);
808 
809  if (result != NULL)
810  {
811  this->Warn("warning", result);
812  }
813 
814  if (Configuration::NextOnRv)
815  {
816  this->Queue1->Next();
817  }
818 }
819 
820 void MainWindow::on_actionRevert_and_warn_triggered()
821 {
822  if (!CheckExit())
823  {
824  return;
825  }
827  {
829  return;
830  }
831 
832  RevertQuery *result = this->Revert("", true, false);
833 
834  if (result != NULL)
835  {
836  this->Warn("warning", result);
837  }
838 
839  if (Configuration::NextOnRv)
840  {
841  this->Queue1->Next();
842  }
843 }
844 
845 void MainWindow::on_actionRevert_triggered()
846 {
847  if (!CheckExit())
848  {
849  return;
850  }
852  {
854  return;
855  }
856  this->Revert();
857 }
858 
859 void MainWindow::on_actionShow_ignore_list_of_current_wiki_triggered()
860 {
861  if (this->Ignore != NULL)
862  {
863  delete this->Ignore;
864  }
865  this->Ignore = new IgnoreList(this);
866  this->Ignore->show();
867 }
868 
869 void MainWindow::on_actionForward_triggered()
870 {
871  if (this->CurrentEdit == NULL)
872  {
873  return;
874  }
875  if (this->CurrentEdit->Next == NULL)
876  {
877  return;
878  }
879  this->ProcessEdit(this->CurrentEdit->Next, true);
880 }
881 
882 void MainWindow::on_actionBack_triggered()
883 {
884  if (this->CurrentEdit == NULL)
885  {
886  return;
887  }
888  if (this->CurrentEdit->Previous == NULL)
889  {
890  return;
891  }
892  this->ProcessEdit(this->CurrentEdit->Previous, true);
893 }
894 
895 void MainWindow::CustomRevert()
896 {
897  if (!CheckExit())
898  {
899  return;
900  }
902  {
904  return;
905  }
906  QAction *revert = (QAction*) QObject::sender();
907  QString k = Core::GetKeyOfWarningTypeFromWarningName(revert->text());
908  QString rs = Core::GetSummaryOfWarningTypeFromWarningKey(k);
909  this->Revert(rs);
910 }
911 
912 void MainWindow::CustomRevertWarn()
913 {
914  if (!CheckExit())
915  {
916  return;
917  }
919  {
921  return;
922  }
923 
924  QAction *revert = (QAction*) QObject::sender();
925  QString k = Core::GetKeyOfWarningTypeFromWarningName(revert->text());
926  QString rs = Core::GetSummaryOfWarningTypeFromWarningKey(k);
927  RevertQuery *result = this->Revert(rs, true, false);
928 
929  if (result != NULL)
930  {
931  this->Warn(k, result);
932  }
933 
934  if (Configuration::NextOnRv)
935  {
936  this->Queue1->Next();
937  }
938 }
939 
940 void MainWindow::CustomWarn()
941 {
943  {
945  return;
946  }
947 
948  QAction *revert = (QAction*) QObject::sender();
949  QString k = Core::GetKeyOfWarningTypeFromWarningName(revert->text());
950 
951  this->Warn(k, NULL);
952 }
953 
954 QString MainWindow::GetSummaryText(QString text)
955 {
956  int id=0;
957  while (id<Configuration::LocalConfig_RevertSummaries.count())
958  {
959  if (text == this->GetSummaryKey(Configuration::LocalConfig_RevertSummaries.at(id)))
960  {
961  QString data = Configuration::LocalConfig_RevertSummaries.at(id);
962  if (data.contains(";"))
963  {
964  data = data.mid(data.indexOf(";") + 1);
965  }
966  return data;
967  }
968  id++;
969  }
970  return Configuration::LocalConfig_DefaultSummary;
971 }
972 
973 void MainWindow::ForceWarn(int level)
974 {
975  if (!CheckExit())
976  {
977  return;
978  }
979 
981  {
983  return;
984  }
985 
986  if (this->CurrentEdit == NULL)
987  {
988  return;
989  }
990 
991  QString __template = "warning" + QString::number(level);
992 
993  QString warning = Core::RetrieveTemplateToWarn(__template);
994 
995  if (warning == "")
996  {
997  /// \todo LOCALIZE ME
998  Core::Log("There is no such warning template " + __template);
999  return;
1000  }
1001 
1002  warning = warning.replace("$2", this->CurrentEdit->GetFullUrl()).replace("$1", this->CurrentEdit->Page->PageName);
1003 
1004  QString title = "Message re " + Configuration::EditSuffixOfHuggle;
1005 
1006  switch (level)
1007  {
1008  case 1:
1009  title = Configuration::LocalConfig_WarnSummary;
1010  break;
1011  case 2:
1012  title = Configuration::LocalConfig_WarnSummary2;
1013  break;
1014  case 3:
1015  title = Configuration::LocalConfig_WarnSummary3;
1016  break;
1017  case 4:
1018  title = Configuration::LocalConfig_WarnSummary4;
1019  break;
1020  }
1021 
1022  title = title.replace("$1", this->CurrentEdit->Page->PageName);
1023  Core::MessageUser(this->CurrentEdit->User, warning, "Your edits to " + this->CurrentEdit->Page->PageName,
1024  title, true);
1025 }
1026 
1028 {
1029  if (ShuttingDown)
1030  {
1031  return;
1032  }
1033  ShuttingDown = true;
1034  this->VandalDock->Disconnect();
1035  QFile *layout = new QFile(Configuration::GetConfigurationPath() + "mainwindow_state");
1036  if (!layout->open(QIODevice::ReadWrite | QIODevice::Truncate))
1037  {
1038  /// \todo LOCALIZE ME
1039  Core::Log("ERROR: Unable to write state to a config file");
1040  } else
1041  {
1042  layout->write(this->saveState());
1043  }
1044  layout->close();
1045  delete layout;
1046  layout = new QFile(Configuration::GetConfigurationPath() + "mainwindow_geometry");
1047  if (!layout->open(QIODevice::ReadWrite | QIODevice::Truncate))
1048  {
1049  /// \todo LOCALIZE ME
1050  Core::Log("ERROR: Unable to write geometry to a config file");
1051  } else
1052  {
1053  layout->write(this->saveGeometry());
1054  }
1055  layout->close();
1056  delete layout;
1058  if (Core::PrimaryFeedProvider != NULL)
1059  {
1061  }
1062  if (this->fWaiting != NULL)
1063  {
1064  delete this->fWaiting;
1065  }
1066  this->fWaiting = new WaitingForm(this);
1067  this->fWaiting->show();
1068  /// \todo LOCALIZE ME
1069  this->fWaiting->Status(10, "Downloading new whitelist");
1070  this->wq = new WLQuery();
1071  this->wq->RegisterConsumer(HUGGLECONSUMER_MAINFORM);
1072  this->wq->Process();
1073  this->wlt = new QTimer(this);
1074  connect(this->wlt, SIGNAL(timeout()), this, SLOT(on_Tick2()));
1075  this->wlt->start(800);
1076 }
1077 
1079 {
1080  if (!CheckExit())
1081  {
1082  return;
1083  }
1085  {
1086  /// \todo LOCALIZE ME
1087  Core::Log("IRC is disabled by project or huggle configuration, you need to enable it first");
1088  return;
1089  }
1090  Core::Log("Reconnecting to IRC");
1092  while (!Core::PrimaryFeedProvider->IsStopped())
1093  {
1094  /// \todo LOCALIZE ME
1095  Core::Log("Waiting for primary feed provider to stop");
1096  Sleeper::usleep(200000);
1097  }
1099  ui->actionIRC->setChecked(true);
1100  ui->actionWiki->setChecked(false);
1102  if (!Core::PrimaryFeedProvider->Start())
1103  {
1104  ui->actionIRC->setChecked(false);
1105  ui->actionWiki->setChecked(true);
1106  /// \todo LOCALIZE ME
1107  Core::Log("ERROR: primary feed provider has failed, fallback to wiki provider");
1111  }
1112 }
1113 
1115 {
1116  return this->EditablePage;
1117 }
1118 
1120 {
1121  if (!this->EditablePage)
1122  {
1123  QMessageBox mb;
1124  mb.setWindowTitle("Cannot perform action");
1125  /// \todo LOCALIZE ME
1126  mb.setText("The action you have requested requires a page to be loaded. Please load a page before trying again.");
1127  mb.exec();
1128  return false;
1129  }
1130 
1131  return true;
1132 }
1133 
1134 void MainWindow::SuspiciousEdit()
1135 {
1136  if (!CheckExit() || !CheckEditableBrowserPage())
1137  {
1138  return;
1139  }
1140  if (this->CurrentEdit != NULL)
1141  {
1142  Hooks::Suspicious(this->CurrentEdit);
1143  this->CurrentEdit->User->setBadnessScore(this->CurrentEdit->User->getBadnessScore() + 1);
1145  }
1146  if (Configuration::NextOnRv)
1147  {
1148  this->Queue1->Next();
1149  }
1150 }
1151 
1153 {
1154  if (ShuttingDown)
1155  {
1156  QMessageBox mb;
1157  mb.setWindowTitle("Error");
1158  /// \todo LOCALIZE ME
1159  mb.setText("Huggle is shutting down, ignored");
1160  mb.exec();
1161  return false;
1162  }
1163 
1164  return true;
1165 }
1166 
1168 {
1169  if (!CheckExit())
1170  {
1171  return;
1172  }
1174  {
1176  return;
1177  }
1178  if (this->CurrentEdit == NULL)
1179  {
1180  return;
1181  }
1182 
1183  this->CurrentEdit->User->Resync();
1184 
1185  if (this->CurrentEdit->User->GetContentsOfTalkPage() != "")
1186  {
1187  /// \todo LOCALIZE ME
1188  if (QMessageBox::question(this, "Welcome :o", "This user doesn't have empty talk page, are you sure you want to send a message to him?", QMessageBox::Yes|QMessageBox::No) == QMessageBox::No)
1189  {
1190  return;
1191  }
1192  }
1193 
1194  if (this->CurrentEdit->User->IsIP())
1195  {
1196  if (this->CurrentEdit->User->GetContentsOfTalkPage() == "")
1197  {
1198  // write something to talk page so that we don't welcome this user twice
1199  this->CurrentEdit->User->SetContentsOfTalkPage(Configuration::LocalConfig_WelcomeAnon);
1200  }
1201  Core::MessageUser(this->CurrentEdit->User, Configuration::LocalConfig_WelcomeAnon
1202  , Configuration::LocalConfig_WelcomeTitle, Configuration::LocalConfig_WelcomeSummary, true);
1203  return;
1204  }
1205 
1206  if (Configuration::LocalConfig_WelcomeTypes.count() == 0)
1207  {
1208  /// \todo LOCALIZE ME
1209  Core::Log("There are no welcome messages defined for this project");
1210  return;
1211  }
1212 
1213  QString message = Core::GetValueFromKey(Configuration::LocalConfig_WelcomeTypes.at(0));
1214 
1215  if (message == "")
1216  {
1217  /// \todo LOCALIZE ME
1218  Core::Log("ERROR: Invalid welcome template, ignored message");
1219  return;
1220  }
1221 
1222  // write something to talk page so that we don't welcome this user twice
1223  this->CurrentEdit->User->SetContentsOfTalkPage(message);
1224  Core::MessageUser(this->CurrentEdit->User, message, Configuration::LocalConfig_WelcomeTitle, Configuration::LocalConfig_WelcomeSummary, true);
1225 }
1226 
1227 void MainWindow::on_actionWelcome_user_triggered()
1228 {
1229  this->Welcome();
1230 }
1231 
1232 void MainWindow::on_actionOpen_in_a_browser_triggered()
1233 {
1234  if (this->CurrentEdit != NULL)
1235  {
1236  QDesktopServices::openUrl(Core::GetProjectWikiURL() + QUrl::toPercentEncoding( this->CurrentEdit->Page->PageName ));
1237  }
1238 }
1239 
1240 void MainWindow::on_actionIncrease_badness_score_by_20_triggered()
1241 {
1242  if (this->CurrentEdit != NULL)
1243  {
1244  this->CurrentEdit->User->setBadnessScore(this->CurrentEdit->User->getBadnessScore() + 200);
1246  }
1247 }
1248 
1249 void MainWindow::on_actionDecrease_badness_score_by_20_triggered()
1250 {
1251  if (this->CurrentEdit != NULL)
1252  {
1253  this->CurrentEdit->User->setBadnessScore(this->CurrentEdit->User->getBadnessScore() - 200);
1255  }
1256 }
1257 
1258 void MainWindow::on_actionGood_edit_triggered()
1259 {
1260  if (this->CurrentEdit != NULL)
1261  {
1262  this->CurrentEdit->User->setBadnessScore(this->CurrentEdit->User->getBadnessScore() - 200);
1263  Hooks::OnGood(this->CurrentEdit);
1265  if (Configuration::LocalConfig_WelcomeGood && this->CurrentEdit->User->GetContentsOfTalkPage() == "")
1266  {
1267  this->Welcome();
1268  }
1269  }
1270  if (Configuration::NextOnRv)
1271  {
1272  this->Queue1->Next();
1273  }
1274 }
1275 
1276 void MainWindow::on_actionTalk_page_triggered()
1277 {
1278  if (this->CurrentEdit == NULL)
1279  {
1280  return;
1281  }
1282  WikiPage *page = new WikiPage(this->CurrentEdit->User->GetTalk());
1283  this->Browser->DisplayPreFormattedPage(page);
1284  delete page;
1285 }
1286 
1287 void MainWindow::on_actionFlag_as_a_good_edit_triggered()
1288 {
1289  if (!CheckExit() || !CheckEditableBrowserPage())
1290  {
1291  return;
1292  }
1293  if (this->CurrentEdit != NULL)
1294  {
1295  Hooks::OnGood(this->CurrentEdit);
1296  this->CurrentEdit->User->setBadnessScore(this->CurrentEdit->User->getBadnessScore() - 200);
1298  if (Configuration::LocalConfig_WelcomeGood && this->CurrentEdit->User->GetContentsOfTalkPage() == "")
1299  {
1300  this->Welcome();
1301  }
1302  }
1303  if (Configuration::NextOnRv)
1304  {
1305  this->Queue1->Next();
1306  }
1307 }
1308 
1309 void MainWindow::on_actionDisplay_this_page_in_browser_triggered()
1310 {
1311  if (this->CurrentEdit != NULL)
1312  {
1313  if (this->CurrentEdit->Diff > 0)
1314  {
1315  QDesktopServices::openUrl(Core::GetProjectScriptURL() + "index.php?diff=" + QString::number(this->CurrentEdit->Diff));
1316  } else
1317  {
1318  QDesktopServices::openUrl(Core::GetProjectWikiURL() + this->CurrentEdit->Page->PageName);
1319  }
1320  }
1321 }
1322 
1323 void MainWindow::on_actionEdit_page_in_browser_triggered()
1324 {
1325  if (this->CurrentEdit != NULL)
1326  {
1327  QDesktopServices::openUrl(Core::GetProjectWikiURL() + this->CurrentEdit->Page->PageName
1328  + "?action=edit");
1329  }
1330 }
1331 
1332 void MainWindow::on_actionDisplay_history_in_browser_triggered()
1333 {
1334  if (this->CurrentEdit != NULL)
1335  {
1336  QDesktopServices::openUrl(Core::GetProjectWikiURL() + this->CurrentEdit->Page->PageName
1337  + "?action=history");
1338  }
1339 }
1340 
1341 void MainWindow::on_actionStop_feed_triggered()
1342 {
1343  ui->actionRemove_old_edits->setChecked(false);
1344  ui->actionStop_feed->setChecked(true);
1345 }
1346 
1347 void MainWindow::on_actionRemove_old_edits_triggered()
1348 {
1349  ui->actionRemove_old_edits->setChecked(true);
1350  ui->actionStop_feed->setChecked(false);
1351 }
1352 
1354 {
1355  if (!CheckExit() || !CheckEditableBrowserPage())
1356  {
1357  return;
1358  }
1359 
1360  if (this->CurrentEdit == NULL)
1361  {
1362  return;
1363  }
1364 
1366  {
1368  return;
1369  }
1370 
1371  if (!this->CurrentEdit->User->IsIP())
1372  {
1373  /// \todo LOCALIZE ME
1374  Core::Log("This feature is for ip users only");
1375  return;
1376  }
1377 
1378  WikiPage *page = new WikiPage(this->CurrentEdit->User->GetTalk());
1379 
1380  /// \todo LOCALIZE ME
1381  Core::EditPage(page, Configuration::LocalConfig_ClearTalkPageTemp
1382  + "\n" + Configuration::LocalConfig_WelcomeAnon,
1383  "Cleaned old templates from talk page " + Configuration::EditSuffixOfHuggle);
1384 
1385  delete page;
1386 }
1387 
1388 void MainWindow::on_actionList_all_QGC_items_triggered()
1389 {
1390  int xx=0;
1391  while (xx<GC::list.count())
1392  {
1393  Collectable *query = GC::list.at(xx);
1394  Core::Log(query->DebugHgc());
1395  xx++;
1396  }
1397 }
1398 
1399 void MainWindow::on_actionRevert_currently_displayed_edit_warn_user_and_stay_on_page_triggered()
1400 {
1401  if (!CheckExit() || !CheckEditableBrowserPage())
1402  {
1403  return;
1404  }
1406  {
1408  return;
1409  }
1410  this->Revert("", false, false);
1411 }
1412 
1413 void MainWindow::on_actionRevert_currently_displayed_edit_and_stay_on_page_triggered()
1414 {
1415  if (!CheckExit() || !CheckEditableBrowserPage())
1416  {
1417  return;
1418  }
1420  {
1422  return;
1423  }
1424 
1425  this->Revert("", true, false);
1426 }
1427 
1428 void MainWindow::on_actionWelcome_user_2_triggered()
1429 {
1430  this->Welcome();
1431 }
1432 
1434 {
1435  if(this->CurrentEdit == NULL)
1436  {
1437  /// \todo LOCALIZE ME
1438  Core::Log("ERROR: No one to report");
1439  return;
1440  }
1441  this->_ReportUser();
1442 }
1443 
1445 {
1446  if(this->CurrentEdit == NULL)
1447  {
1448  /// \todo LOCALIZE ME
1449  Core::Log("ERROR: No one to report");
1450  return;
1451  }
1452  this->_ReportUser();
1453 }
1454 
1455 void MainWindow::on_actionWarning_1_triggered()
1456 {
1457  this->ForceWarn(1);
1458 }
1459 
1460 void MainWindow::on_actionWarning_2_triggered()
1461 {
1462  this->ForceWarn(2);
1463 }
1464 
1465 void MainWindow::on_actionWarning_3_triggered()
1466 {
1467  this->ForceWarn(3);
1468 }
1469 
1470 void MainWindow::on_actionWarning_4_triggered()
1471 {
1472  this->ForceWarn(4);
1473 }
1474 
1475 void MainWindow::on_actionEdit_user_talk_triggered()
1476 {
1477  if (this->CurrentEdit != NULL)
1478  {
1479  QDesktopServices::openUrl(Core::GetProjectWikiURL() + this->CurrentEdit->User->GetTalk()
1480  + "?action=edit");
1481  }
1482 }
1483 
1484 void MainWindow::on_actionReconnect_IRC_triggered()
1485 {
1486  ReconnectIRC();
1487 }
1488 
1489 void MainWindow::on_actionRequest_speedy_deletion_triggered()
1490 {
1491  this->RequestPD();
1492 }
1493 
1495 {
1496 #if !PRODUCTION_BUILD
1497  if (!CheckExit() || !CheckEditableBrowserPage())
1498  {
1499  return;
1500  }
1501  if (this->CurrentEdit == NULL)
1502  {
1503  /// \todo LOCALIZE ME
1504  Core::Log("ERROR: No, you cannot delete an NULL page :)");
1505  return;
1506  }
1507  this->fDeleteForm = new DeleteForm(this);
1508  fDeleteForm->setPage(this->CurrentEdit->Page);
1509  fDeleteForm->show();
1510 #endif
1511 }
1512 
1514 {
1515 #if !PRODUCTION_BUILD
1516  if (!CheckExit() || !CheckEditableBrowserPage())
1517  {
1518  return;
1519  }
1520 
1521  if(this->CurrentEdit == NULL)
1522  {
1523  /// \todo LOCALIZE ME
1524  Core::Log("ERROR: No one to block :o");
1525  return;
1526  }
1527  this->fBlockForm = new BlockUser(this);
1528  this->CurrentEdit->User->Resync();
1529  fBlockForm->SetWikiUser(this->CurrentEdit->User);
1530  fBlockForm->show();
1531 #endif
1532 }
1533 
1534 void Huggle::MainWindow::on_actionIRC_triggered()
1535 {
1536  ReconnectIRC();
1537 }
1538 
1540 {
1541  if (!CheckExit() || !CheckEditableBrowserPage())
1542  {
1543  return;
1544  }
1545  /// \todo LOCALIZE ME
1546  Core::Log("Switching to wiki provider");
1548  ui->actionIRC->setChecked(false);
1549  ui->actionWiki->setChecked(true);
1550  while (!Core::PrimaryFeedProvider->IsStopped())
1551  {
1552  /// \todo LOCALIZE ME
1553  Core::Log("Waiting for primary feed provider to stop");
1554  Sleeper::usleep(200000);
1555  }
1559 }
1560 
1561 void Huggle::MainWindow::on_actionShow_talk_triggered()
1562 {
1563  this->EditablePage = false;
1564  this->Browser->DisplayPreFormattedPage(Core::GetProjectScriptURL() + "index.php?title=User_talk:" + Configuration::UserName);
1565 }
1566 
1568 {
1569  if (!CheckExit() || !CheckEditableBrowserPage())
1570  {
1571  return;
1572  }
1573  if (this->CurrentEdit == NULL)
1574  {
1575  /// \todo LOCALIZE ME
1576  Core::Log("ERROR: Cannot protect NULL page");
1577  return;
1578  }
1579  this->fProtectForm = new ProtectPage(this);
1581  fProtectForm->show();
1582 }
1583 
1585 {
1586  /// \todo LOCALIZE ME
1587  Core::Log("Current number of edits in memory: " + QString::number(WikiEdit::EditList.count()));
1588 }
1589 
1590 void Huggle::MainWindow::on_actionFlag_as_suspicious_edit_triggered()
1591 {
1592  this->SuspiciousEdit();
1593 }
1594 
1595 void Huggle::MainWindow::on_actionDisconnect_triggered()
1596 {
1597  this->VandalDock->Disconnect();
1598 }
1599 
1601 {
1602  if (!CheckExit() || !CheckEditableBrowserPage())
1603  {
1604  return;
1605  }
1606  if (this->CurrentEdit == NULL)
1607  {
1608  return;
1609  }
1610  if (Configuration::LocalConfig_UAAavailable)
1611  {
1612  QMessageBox dd;
1613  dd.setIcon(dd.Information);
1614  /// \todo LOCALIZE ME
1615  dd.setWindowTitle("UAA not available");
1616  /// \todo LOCALIZE ME
1617  dd.setText("The usernames for administrator attention noticeboard is not available on your wiki.");
1618  dd.exec();
1619  }
1620  if (this->CurrentEdit->User->IsIP())
1621  {
1622  /// \todo LOCALIZE ME
1623  Core::Log("ERROR: You can't report an IP to UAA!");
1624  return;
1625  }
1626  this->fUaaReportForm = new UAAReport();
1628  fUaaReportForm->show();
1629 }
1630 
1631 void Huggle::MainWindow::on_actionShow_list_of_score_words_triggered()
1632 {
1633  if (this->fScoreWord != NULL)
1634  {
1635  delete this->fScoreWord;
1636  }
1637  this->fScoreWord = new ScoreWordsDbForm(this);
1638  this->fScoreWord->show();
1639 }
1640 
1641 void Huggle::MainWindow::on_actionRevert_AGF_triggered()
1642 {
1643  if (!CheckExit())
1644  {
1645  return;
1646  }
1648  {
1650  return;
1651  }
1652  this->Revert(Configuration::LocalConfig_AgfRevert);
1653 }
1654 
1655 void Huggle::MainWindow::on_actionDisplay_a_session_data_triggered()
1656 {
1657  if (this->fSessionData != NULL)
1658  {
1659  delete this->fSessionData;
1660  }
1661  this->fSessionData = new SessionForm(this);
1662  this->fSessionData->show();
1663 }
QString GetContentsOfTalkPage()
GetContentsOfTalkPage returns a precached content of this users talk page If there is a global instan...
Definition: wikiuser.cpp:191
static QString GetProjectScriptURL()
Return a script url like http://en.wikipedia.org/w/.
Definition: core.cpp:674
Web browser.
Definition: huggleweb.hpp:31
void Process()
Execute query.
Definition: wlquery.cpp:26
Huggle is updating a config of user.
Definition: mainwindow.hpp:104
static QString GetProjectWikiURL()
Return a full url like http://en.wikipedia.org/wiki/.
Definition: core.cpp:669
Primary huggle window.
Definition: mainwindow.hpp:110
void on_actionProtect_triggered()
void setPageToProtect(WikiPage *Page)
set a page that is supposed to be protected, this needs to be called by owner who created this form ...
Definition: protectpage.cpp:42
bool BrowserPageIsEditable()
Returns true if current page can be edited.
Form that can be displayed from help menu, should list all developers.
Definition: aboutform.hpp:25
QMenu * RevertSummaries
Revert menu.
Definition: mainwindow.hpp:157
bool Warn(QString WarningType, RevertQuery *dependency)
Definition: mainwindow.cpp:423
static void Log(QString Message)
Write text to terminal as well as ring log.
Definition: core.cpp:563
Base for all items that are supposed to be collected by garbage collector.
Definition: collectable.hpp:34
History * _History
Pointer to history.
Definition: mainwindow.hpp:142
void on_actionReport_user_2_triggered()
QMenu * WarnMenu
Warning menu.
Definition: mainwindow.hpp:155
void on_actionDelete_triggered()
static QString UserName
User name.
List of processes in a main window.
Definition: processlist.hpp:50
Report user.
Definition: reportuser.hpp:39
QList< WikiEdit * > PendingEdits
List of edits that are being saved.
Definition: mainwindow.hpp:116
The window that is used to report a page for deletion.
Definition: speedyform.hpp:34
void on_actionReport_user_triggered()
HuggleWeb * Browser
Pointer to browser.
Definition: mainwindow.hpp:122
QList< WikiEdit * > Historical
List of all edits that are kept in history, so that we can track them and delete them.
Definition: mainwindow.hpp:268
static QString GetConfigurationPath()
Return a configuration path.
static bool Restricted
When this is true most of functions will not work.
static void PostProcessEdit(WikiEdit *_e)
Definition: core.cpp:774
void setUserForUAA(WikiUser *user)
I don&#39;t have much of a clue why this is here lol, but I know the dialog can&#39;t be initialised from mai...
Definition: uaareport.cpp:41
EditQuery * eq
Pointer to query that is used to store user config on exit of huggle.
Definition: mainwindow.hpp:151
Whitelist query :o.
Definition: wlquery.hpp:23
virtual bool Processed()
Returns true in case that query is processed.
Definition: query.cpp:45
void on_actionWiki_triggered()
BlockUser * fBlockForm
Pointer to a form to block user.
Definition: mainwindow.hpp:166
This form can be used to block users from editing, which requires the block permission.
Definition: blockuser.hpp:37
bool IsIP()
Returns true in case the current user is IP user.
Definition: wikiuser.cpp:240
void UnregisterConsumer(const int consumer)
This function will remove a string which prevent the object from being removed.
Definition: collectable.cpp:68
void RegisterConsumer(const int consumer)
Registers a consumer.
Definition: collectable.cpp:57
void DisplayPreFormattedPage(WikiPage *page)
Retrieve a page in render mode on currently selected project.
Definition: huggleweb.cpp:33
bool SetUser(WikiUser *u)
Set a user.
Definition: reportuser.cpp:53
Preferences * preferencesForm
Pointer to options.
Definition: mainwindow.hpp:128
RevertQuery * Revert(QString summary="", bool nd=false, bool next=true)
Definition: mainwindow.cpp:384
VandalNw * VandalDock
Pointer to vandal network.
Definition: mainwindow.hpp:148
void ProcessEdit(WikiEdit *e, bool IgnoreHistory=false)
Recreate interface, should be called everytime you do anything with main form.
Definition: mainwindow.cpp:258
QLabel * Status
Status bar.
Definition: mainwindow.hpp:264
The RevertQuery class can be used to rollback any edit.
Definition: revertquery.hpp:32
QString Username
Username.
Definition: wikiuser.hpp:52
static Message * MessageUser(WikiUser *user, QString message, QString title, QString summary, bool section=true, Query *dependency=NULL)
MessageUser Message user.
Definition: core.cpp:427
long getBadnessScore(bool _resync=true)
Retrieve a badness score for current user, see WikiUser::BadnessScore for more.
Definition: wikiuser.cpp:271
This window contains all the messages that are stored in ring log.
Definition: hugglelog.hpp:28
AboutForm * aboutForm
Pointer to about dialog (see aboutform.h)
Definition: mainwindow.hpp:132
The UserinfoForm class is a widget that displays the information about user including their history a...
History of actions done by user.
Definition: history.hpp:57
static QList< WikiEdit * > EditList
This list contains reference to all existing edits in memory.
Definition: wikiedit.hpp:71
static void DeleteEdit(WikiEdit *edit)
Remove edit in proper manner.
Definition: core.cpp:178
static void CheckQueries()
Check if all running queries are finished and if so it removes them from list.
Definition: core.cpp:786
int WarningLevel
Current warning level of user.
Definition: wikiuser.hpp:54
This is a very simple provider of changes that basically refresh recent changes every 6 seconds...
QString DebugHgc()
DebugHgc.
Huggle is downloading a whitelist in order to update it.
Definition: mainwindow.hpp:100
static void Shutdown()
Terminate the process, call this after you release all resources and finish all queries.
Definition: core.cpp:684
Mediawiki page.
Definition: wikipage.hpp:43
Huggle is updating the whitelist.
Definition: mainwindow.hpp:102
static RevertQuery * RevertEdit(WikiEdit *_e, QString summary="", bool minor=false, bool rollback=true, bool keep=false)
RevertEdit Reverts the edit.
Definition: core.cpp:855
static bool UsingIRC
Whether IRC is being used.
WLQuery * wq
This query is used to refresh white list.
Definition: mainwindow.hpp:153
static HuggleFeed * PrimaryFeedProvider
Pointer to primary feed provider.
Definition: core.hpp:119
void Resync()
Update the information of this user based on global user list.
Definition: wikiuser.cpp:174
void Disconnect()
Definition: vandalnw.cpp:50
void on_actionBlock_user_triggered()
void on_actionReport_username_triggered()
Huggle is not shutting down.
Definition: mainwindow.hpp:98
QStringList UnwrittenLogs
Definition: mainwindow.hpp:140
static QStringList WhiteList
Data of wl.
virtual bool Start()
Start the feed engine.
Definition: hugglefeed.hpp:34
static void DeleteOld()
Function that walks through the list and delete these that can be deleted.
Definition: gc.cpp:16
virtual void Stop()
Stop the feed engine.
Definition: hugglefeed.hpp:32
Toolbar on top of window.
Definition: huggletool.hpp:35
static int Cache_InfoSize
Size of info cache.
HuggleQueue * Queue1
Pointer to queue.
Definition: mainwindow.hpp:120
ProcessList * Queries
Pointer to processes.
Definition: mainwindow.hpp:137
bool IsPostProcessed()
Return true in case this edit was post processed already.
Definition: wikiedit.cpp:297
Queue of edits.
Definition: hugglequeue.hpp:36
IgnoreList * Ignore
Pointer to ignore list (see ignorelist.h)
Definition: mainwindow.hpp:130
static QList< WikiUser * > ProblematicUsers
List of users that are scored in this instance of huggle.
Definition: wikiuser.hpp:35
Every exception raised by huggle is defined by this class.
Definition: exception.hpp:20
static int HistorySize
Number of edits to keep in history stack.
int Diff
Diff id.
Definition: wikiedit.hpp:99
virtual void Resume()
Resume edit parsing.
Definition: hugglefeed.hpp:38
static QString MakeLocalUserConfig()
This function creates a user configuration that is stored on wiki.
UAAReport * fUaaReportForm
Pointer to UAA dialog.
Definition: mainwindow.hpp:173
static unsigned int Verbosity
Verbosity for debugging to terminal etc, can be switched with parameter –verbosity.
ShutdownOp Shutdown
If system is shutting down this is displaying which part of shutdown is currently being executed...
Definition: mainwindow.hpp:162
static void DeveloperError()
Display a message box telling user that function is not allowed during developer mode.
Definition: core.cpp:738
bool Processed()
Returns true in case that query is processed.
Definition: editquery.cpp:49
HuggleLog * SystemLog
Pointer to syslog.
Definition: mainwindow.hpp:118
The ProtectPage class display a window where user can protect a page given they have the permissions ...
Definition: protectpage.hpp:36
QMutex lUnwrittenLogs
Mutex we lock unwritten logs with so that only 1 thread can write to it.
Definition: mainwindow.hpp:144
static WikiSite Project
currently selected project
static QList< WikiEdit * > ProcessingEdits
Definition: core.hpp:124
void on_actionEdit_info_triggered()
static QString EditSuffixOfHuggle
Suffix used by huggle.
Preferences window.
Definition: preferences.hpp:29
WikiUser * User
User who changed the page.
Definition: wikiedit.hpp:89
static void DebugLog(QString Message, unsigned int Verbosity=1)
This log is only shown if verbosity is same or larger than requested verbosity.
Definition: core.cpp:641
WikiEdit * CurrentEdit
Pointer to current edit, if it&#39;s NULL there is no edit being displayed.
Definition: mainwindow.hpp:134
Provider that uses a wikimedia irc recent changes feed to retrieve information about edits...
A window that contains ignore list.
Definition: ignorelist.hpp:26
QMenu * RevertWarn
Pointer to menu of revert warn button.
Definition: mainwindow.hpp:146
void ForceWarn(int level)
Send a template to user no matter if they can be messaged or not.
Definition: mainwindow.cpp:973
MainWindow(QWidget *parent=0)
Definition: mainwindow.cpp:16
Session info.
Definition: sessionform.h:27
QString GetFullUrl()
Return a full url to edit.
Definition: wikiedit.cpp:291
virtual WikiEdit * RetrieveEdit()
Return a last edit from cache or NULL.
Definition: hugglefeed.hpp:48
HuggleTool * tb
Pointer to toolbar.
Definition: mainwindow.hpp:126
static bool WhitelistDisabled
Whitelist is not useable.
DeleteForm * fDeleteForm
Pointer to a form to delete a page.
Definition: mainwindow.hpp:168
Wiki edit.
Definition: wikiedit.hpp:67
static QStringList RingLogToQStringList()
Return a ring log as qstring list.
Definition: core.cpp:724
QString GetTalk()
Return a link to talk page of this user (like User talk:Jimbo)
Definition: wikiuser.cpp:245
void Welcome()
Welcome user.
void RequestPD()
Request a page deletion csd or afd and so on.
Definition: mainwindow.cpp:347
Form to report users to UAA.
Definition: uaareport.hpp:36
void on_actionClear_talk_page_of_user_triggered()
void DisplayDiff(WikiEdit *edit)
Definition: huggleweb.cpp:81
void Update(WikiEdit *edit)
Definition: historyform.cpp:29
This is a delete form.
Definition: deleteform.hpp:38
bool CheckEditableBrowserPage()
CheckEditableBrowserPage will check if current page is editable and if it&#39;s not it display a message ...
Vandalism network.
Definition: vandalnw.hpp:32
static bool PreflightCheck(WikiEdit *_e)
Check if we can revert this edit.
Definition: core.cpp:835
static QString WelcomeMP
Where the welcome message is stored.
QString PageName
Name of page.
Definition: wikipage.hpp:48
This is universal form that is just displaying the progress bar and reason why we need to wait...
Definition: waitingform.hpp:25
WikiPage * Page
Page that was changed by edit.
Definition: wikiedit.hpp:87
void SetContentsOfTalkPage(QString text)
SetContentsOfTalkPage Change a cache for talk page in local and global cache.
Definition: wikiuser.cpp:212
static void UpdateUser(WikiUser *us)
Update a list of problematic users.
Definition: wikiuser.cpp:59
It can be used to retrieve a history of currently displayed page.
Definition: historyform.hpp:29
QString Data
Data retrieved by query.
Definition: queryresult.hpp:25
static QList< Collectable * > list
List of all managed queries that qgc keeps track of.
Definition: gc.hpp:42
QueryResult * Result
Result of query, see documentation of QueryResult for more.
Definition: query.hpp:68
ProtectPage * fProtectForm
Pointer to a form to protect a page.
Definition: mainwindow.hpp:171
virtual void Pause()
This is useful to stop parsing edits from irc and like in case that queue is full.
Definition: hugglefeed.hpp:36