diff Squawk.lua @ 10:2231fd3f139b

Qtip added for LDB
author wobin
date Thu, 23 Apr 2009 04:11:42 +1000
parents c535960b1245
children 0ca5ec0b7502
line wrap: on
line diff
--- a/Squawk.lua	Sun Apr 19 02:50:40 2009 +1000
+++ b/Squawk.lua	Thu Apr 23 04:11:42 2009 +1000
@@ -81,7 +81,7 @@
 	local o = {}
 	o.Owner = Owner or UnitName("player")
 	o.Message = Message
-	o.Time = os.time()
+	o.Time = time()
 	local reply, to = strsplit("@", ((strsplit(" ", Message))))
 	if reply == "" then
 		o.ReplyTo = to
@@ -116,6 +116,10 @@
 	return Settings.Private
 end
 
+function Settings:TogglePrivate()
+	Settings.Private = not Settings.Private
+end
+
 function Settings:AddFollower(Name)
 	Settings.Follower[Name] = 1
 	self:RemovePending(Name)
@@ -205,32 +209,36 @@
 end
 
 function Controller:AddANewSquawk(Name, Message, Source)
-	if not Model.Blocked[Name] then
+	if not Settings.Blocked[Name] then
 	
 		if Source == "WHISPER" then
-			if Model.Requested[Name] then -- We've been approved offline!
-				Model:AddFollowing(Name)
+			if Settings.Requested[Name] then -- We've been approved offline!
+				Settings:AddFollowing(Name)
 			end
 
-			if not Model.Following[Name] then -- If we're no longer following this person
+			if not Settings.Following[Name] then -- If we're no longer following this person
 				self:SendMessageToTarget(Name, "#Unfollow|"..UnitName("player"))
 				return
 			end
-	
-			table.insert(Model.Squawks, Squawk:new(Message, Name))
-			View:UpdateSquawkList()
+		end	
+		
+		if Source == "GUILD" and Name == UnitName("player") then
+			return
 		end
+
+		table.insert(Model.Squawks, Squawk:new(Message, Name))
+		View:UpdateSquawkList()	
 	end
 end
 
 function Controller:SendNewSquawk(Message)
-	if not Model:IsPrivate() then
+	if not Settings:IsPrivate() then
 		self:SendMessageToGuild("#Squawk|"..UnitName("player").."|"..Message)
 	end
 
 	self:AddANewSquawk(UnitName("player"), Message)
 	
-	for name, _ in pairs(Model.Following) do
+	for name, _ in pairs(Settings.Following) do
 		self:SendMessageToTarget(name, "#Squawk|"..UnitName("player").."|"..Message)
 	end
 end
@@ -243,8 +251,14 @@
 	View:NotifyOfPendingRequest(Name)
 end
 
+function Controller:ApprovePendingRequest(Name)
+	Settings:AddFollower(Name)
+	View:NotifyOfNewFollower(Name)
+	self:SendMessageToTarget(Name, "#Follow|"..UnitName("player"))
+end
+
 function Controller:SendMessageToTarget(Name, Message)
-	self:SendCommMessage("Squawk", Message, "WHISPER", Name, "BULK")
+	self:SendCommMessage("Squawk", Message, "WHISPER", Name)
 end
 
 function Controller:SendMessageToGuild(Message)
@@ -259,9 +273,10 @@
 		["#Request"] = Controller.TheyWantToFollowMe,
 	}
 
-function Controller:ReceiveMessage(Prefix, Message, Distribution, Sender)
+function Controller:ReceiveMessage(Message, Distribution, Sender)
 	local command, name, info = strsplit("|",Message)
-	Parse[command](self, name, info, Distribution)
+	View:Print(Distribution..":"..Message)
+	Parse[command](Controller, name, info, Distribution)
 end
 -- View --
 
@@ -316,3 +331,22 @@
 		self:Print(name)
 	end
 end
+
+local LDBFeed = LibStub("LibDataBroker-1.1"):NewDataObject("Squawk", {type = "data source", text = "Awk!"})
+local QTip = LibStub("LibQTip-1.0")
+
+function LDBFeed:OnEnter()
+	local tooltip = QTip:Acquire("Squawk",3, "LEFT", "LEFT", "RIGHT")
+	self.tooltip = tooltip
+	tooltip:AddHeader('Name')
+	tooltip:AddLine('testUser', 'Squawk!', '3 min ago')
+	tooltip:SmartAnchorTo(self)
+	tooltip:Show()
+end
+
+function LDBFeed:OnTooltipShow()
+end
+
+function LDBFeed:OnLeave()
+	QTip:Release(self.tooltip)
+end