diff -urN -X psidiff.ignore sources/src/chatdlg.cpp work/src/chatdlg.cpp
--- sources/src/chatdlg.cpp	2009-07-25 21:56:42.000000000 +0600
+++ work/src/chatdlg.cpp	2009-07-25 21:57:54.000000000 +0600
@@ -191,12 +191,6 @@
 	connect(act_scrolldown_, SIGNAL(activated()), SLOT(scrollDown()));
 }
 
-void ChatDlg::ensureTabbedCorrectly() {
-	TabbableWidget::ensureTabbedCorrectly();
-	setShortcuts();
-}
-
-
 void ChatDlg::setShortcuts()
 {
 	act_send_->setShortcuts(ShortcutManager::instance()->shortcuts("chat.send"));
@@ -427,6 +421,14 @@
 	return u;
 }
 
+void ChatDlg::ensureTabbedCorrectly() {
+        TabbableWidget::ensureTabbedCorrectly();
+        setShortcuts();
+        QList<UserListItem*> ul = account()->findRelevant(jid());
+        UserStatus userStatus = userStatusFor(jid(), ul, false);
+        setTabIcon(PsiIconset::instance()->statusPtr(jid(), userStatus.statusType)->icon());
+}
+
 void ChatDlg::updateContact(const Jid &j, bool fromPresence)
 {
 	// if groupchat, only update if the resource matches
diff -urN -X psidiff.ignore sources/src/groupchatdlg.cpp work/src/groupchatdlg.cpp
--- sources/src/groupchatdlg.cpp	2009-07-25 21:56:43.000000000 +0600
+++ work/src/groupchatdlg.cpp	2009-07-25 21:57:54.000000000 +0600
@@ -808,6 +808,7 @@
 	QList<int> tmp = ui_.hsplitter->sizes();
 	ui_.hsplitter->setSizes(QList<int>() << 0);
 	ui_.hsplitter->setSizes(tmp);
+       setStatusTabIcon((d->state == Private::Connected ? STATUS_ONLINE : STATUS_OFFLINE));
 }
 
 void GCMainDlg::setShortcuts()
@@ -1087,6 +1088,7 @@
 	if(d->state != Private::Idle && d->state != Private::ForcedLeave) {
 		d->state = Private::Idle;
 		ui_.pb_topic->setEnabled(false);
+               setStatusTabIcon(STATUS_OFFLINE);
 		appendSysMsg(tr("Disconnected."), true);
 		ui_.mle->chatEdit()->setEnabled(false);
 	}
@@ -1173,6 +1175,7 @@
 void GCMainDlg::error(int, const QString &str)
 {
 	ui_.pb_topic->setEnabled(false);
+       setStatusTabIcon(STATUS_ERROR);
 
 	if(d->state == Private::Connecting)
 		appendSysMsg(tr("Unable to join groupchat.	Reason: %1").arg(str), true);
@@ -1505,6 +1508,7 @@
 		ui_.lv_users->clear();
 		d->state = Private::Connected;
 		ui_.pb_topic->setEnabled(true);
+               setStatusTabIcon(STATUS_ONLINE);
 		ui_.mle->chatEdit()->setEnabled(true);
 		setConnecting();
 		appendSysMsg(tr("Connected."), true);
@@ -1876,6 +1880,10 @@
 	return d->pending;
 }
 
+void GCMainDlg::setStatusTabIcon(int status) {
+    setTabIcon(PsiIconset::instance()->statusPtr(jid(), status)->icon());
+}
+
 //----------------------------------------------------------------------------
 // GCFindDlg
 //----------------------------------------------------------------------------
diff -urN -X psidiff.ignore sources/src/groupchatdlg.h work/src/groupchatdlg.h
--- sources/src/groupchatdlg.h	2009-07-25 21:56:42.000000000 +0600
+++ work/src/groupchatdlg.h	2009-07-25 21:57:54.000000000 +0600
@@ -92,6 +92,7 @@
 	void closeEvent(QCloseEvent *);
 	void resizeEvent(QResizeEvent*);
 	void mucInfoDialog(const QString& title, const QString& message, const Jid& actor, const QString& reason);
+       void setStatusTabIcon(int status);
 
 signals:
 	void aSend(const Message &);
diff -urN -X psidiff.ignore sources/src/psichatdlg.cpp work/src/psichatdlg.cpp
--- sources/src/psichatdlg.cpp	2009-07-25 21:56:42.000000000 +0600
+++ work/src/psichatdlg.cpp	2009-07-26 02:05:44.000000000 +0600
@@ -154,6 +154,7 @@
 
 	PsiToolTip::install(ui_.lb_status);
 	ui_.lb_status->setPsiIcon(IconsetFactory::iconPtr("status/noauth"));
+	setTabIcon(IconsetFactory::iconPtr("status/noauth")->icon());
 
 	ui_.tb_emoticons->setIcon(IconsetFactory::icon("psi/smile").icon());
 
@@ -375,9 +376,11 @@
 
 	if (status == -1 || !u) {
 		ui_.lb_status->setPsiIcon(IconsetFactory::iconPtr("status/noauth"));
+               setTabIcon(IconsetFactory::iconPtr("status/noauth")->icon());
 	}
 	else {
 		ui_.lb_status->setPsiIcon(PsiIconset::instance()->statusPtr(jid(), status));
+               setTabIcon(PsiIconset::instance()->statusPtr(jid(), status)->icon());
 	}
 
 	if (u) {
diff -urN -X psidiff.ignore sources/src/tabs/tabbablewidget.cpp work/src/tabs/tabbablewidget.cpp
--- sources/src/tabs/tabbablewidget.cpp	2009-07-23 01:37:51.000000000 +0600
+++ work/src/tabs/tabbablewidget.cpp	2009-07-26 01:41:39.000000000 +0600
@@ -207,3 +207,18 @@
 		}
 	}
 }
+
+/**
+ * Set the icon of the tab.
+ */
+void TabbableWidget::setTabIcon(const QIcon &icon) {
+	icon_ = icon;
+    TabDlg* tabDlg = tabManager_->getManagingTabs(this);
+    if (tabDlg) {
+        tabDlg->setTabIcon(this, icon);
+    }
+}
+
+const QIcon &TabbableWidget::icon() const {
+	return icon_;
+}
diff -urN -X psidiff.ignore sources/src/tabs/tabbablewidget.h work/src/tabs/tabbablewidget.h
--- sources/src/tabs/tabbablewidget.h	2009-07-23 01:37:51.000000000 +0600
+++ work/src/tabs/tabbablewidget.h	2009-07-26 01:41:23.000000000 +0600
@@ -21,6 +21,7 @@
 #ifndef TABBABLE_H
 #define TABBABLE_H
 
+#include <QIcon>
 #include "advwidget.h"
 #include "im.h" // ChatState
 
@@ -77,6 +77,9 @@ public slots:
 protected:
 	virtual void setJid(const Jid&);
 	PsiAccount* account() const;
+public:
+	void setTabIcon(const QIcon &);
+	const QIcon &icon() const;
 
 	// reimplemented
 	void changeEvent(QEvent* e);
@@ -85,6 +88,7 @@
 	Jid jid_;
 	PsiAccount *pa_;
 	TabManager *tabManager_;
+	QIcon icon_;
 };
 
 #endif
diff -urN -X psidiff.ignore sources/src/tabs/tabdlg.cpp work/src/tabs/tabdlg.cpp
--- sources/src/tabs/tabdlg.cpp	2009-07-23 01:37:51.000000000 +0600
+++ work/src/tabs/tabdlg.cpp	2009-07-26 02:02:00.000000000 +0600
@@ -362,7 +362,7 @@
 {
 	setUpdatesEnabled(false);
 	tabs_.append(tab);
-	tabWidget_->addTab(tab, captionForTab(tab));
+	tabWidget_->addTab(tab, captionForTab(tab), tab->icon());
 
 	connect(tab, SIGNAL(invalidateTabInfo()), SLOT(updateTab()));
 	connect(tab, SIGNAL(updateFlashState()), SLOT(updateFlashState()));
@@ -756,3 +756,10 @@
 	simplifiedCaption_ = enabled;
 	updateCaption();
 }
+
+/**
+ * Set the icon of the tab.
+ */
+void TabDlg::setTabIcon(QWidget *widget,const QIcon &icon) {
+    tabWidget_->setTabIcon(widget, icon);
+}
diff -urN -X psidiff.ignore sources/src/tabs/tabdlg.h work/src/tabs/tabdlg.h
--- sources/src/tabs/tabdlg.h	2009-07-23 01:37:51.000000000 +0600
+++ work/src/tabs/tabdlg.h	2009-07-25 21:57:54.000000000 +0600
@@ -83,6 +83,7 @@ public:
 	void setUserManagementEnabled(bool enabled); // default enabled
 	void setTabBarShownForSingles(bool enabled); // default enabled
 	void setSimplifiedCaptionEnabled(bool enabled); // default disabled
+        void setTabIcon(QWidget *,const QIcon &);
 
 protected:
 	void setShortcuts();
diff -urN -X psidiff.ignore sources/src/widgets/psitabwidget.cpp work/src/widgets/psitabwidget.cpp
--- sources/src/widgets/psitabwidget.cpp	2009-07-23 01:37:51.000000000 +0600
+++ work/src/widgets/psitabwidget.cpp	2009-07-26 02:01:29.000000000 +0600
@@ -147,14 +147,14 @@
 /**
  * Add the Widget to the tab stack.
  */
-void PsiTabWidget::addTab(QWidget *widget, QString name) {
+void PsiTabWidget::addTab(QWidget *widget, QString name, const QIcon &icon) {
 	Q_ASSERT(widget);
 	if (widgets_.contains(widget)) {
 		return;
 	}
 	widgets_.append(widget);
 	stacked_->addWidget(widget);
-	tabBar_->addTab(name);
+	tabBar_->addTab(icon, name);
 	showPage(currentPage());
 } 
 
@@ -222,6 +222,17 @@
 	tabBar_->setTabText(index, label);
 } 
 
+/**
+ * Set the icon of the tab.
+ */
+void PsiTabWidget::setTabIcon(QWidget *widget, const QIcon &icon) {
+        int index = getIndex(widget);
+        if (index == -1) {
+                return;
+        }
+        tabBar_->setTabIcon(index, icon);
+}
+
 void PsiTabWidget::setCurrentPage(int index) {
 	Q_ASSERT(index >=0 && index < count());
 	showPage(widgets_[index]);
diff -urN -X psidiff.ignore sources/src/widgets/psitabwidget.h work/src/widgets/psitabwidget.h
--- sources/src/widgets/psitabwidget.h	2009-07-23 01:37:51.000000000 +0600
+++ work/src/widgets/psitabwidget.h	2009-07-26 02:01:33.000000000 +0600
@@ -48,7 +48,7 @@
 	QWidget *currentPage();
 	int currentPageIndex();
 	QWidget *widget(int index);
-	void addTab(QWidget *, QString);
+	void addTab(QWidget *, QString, const QIcon &icon = QIcon());
 	void showPage(QWidget *);
 	void showPageDirectly(QWidget *);
 
@@ -56,6 +56,7 @@
 	QWidget* page(int index);
 	int getIndex(QWidget *);
 	void setTabText(QWidget *, const QString &);
+	void setTabIcon(QWidget *, const QIcon &);
 	void setTabPosition(QTabWidget::TabPosition pos);
 	void setCloseIcon(const QIcon &);
 
