LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-17-2010, 01:10 PM   #1
Neethusha
LQ Newbie
 
Registered: Feb 2010
Posts: 16

Rep: Reputation: 0
Firefox Extension: about communication with the server


How can an extension communicate with a server?

how do they exchange data?

suppose u sign in to a page, how does the connection between th extension and server be after sign in?

how does the server send a message to one of these signed in clients?

i tried the communication part in ajax httprequest response objects...the javascript n php are communicating...but wen i integrated the code into the extension, it din give output.

i heard that ajax wont work well in the backend in xul applications..something about xml render....is there any other way for carrying out this extension server communication...
 
Old 03-17-2010, 01:17 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966
An extension of what??
 
Old 03-17-2010, 11:36 PM   #3
Neethusha
LQ Newbie
 
Registered: Feb 2010
Posts: 16

Original Poster
Rep: Reputation: 0
a Mozilla Firefox extension which connects two or more people located at geographically distant areas, who happen to be browsing the same website simultaneously. It shows you other people who visit the same websites as you are.

The extension informs the server whenever the user clicks the EnableChat button to start a chat session.
The server retrieves from its database, the list of users who are currently online in that site and returns it.
The user can then click on any username for opening a chat session.

this is my xul file:
<?xml version="1.0"?>

<overlay id="blaze-overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<script language="javascript" type="text/javascript" src="chrome://blaze/content/connect.js" />


<toolbox id="navigator-toolbox">
<toolbar id="blaze-toolbar" align="center" toolbarname="blaze" accesskey="B" class="chromeclass-toolbar" context="toolbar-context-menu" hidden="false" persist="hidden">

<label control="some-text" value="Username"/>
<textbox id="some-text"/>
<label control="some-password" value="Password" />
<textbox id="Userpassword" type="password" maxlength="15" onkeypress="if(event.keyCode == 13){alert('good');verifyusernamepasswd();}"/>

<toolbarbutton id="blaze-button" tooltiptext="Click for chat with other users"
label="Enable Chat" oncommand="getUsers('php.com');" />

<toolbarbutton id="blaze-logout" tooltiptext="Click to log out of BLAZE" label="Logout" oncommand="alert('bye!')" />
</toolbar>
</toolbox>


<statusbar id="status-bar">
<statusbarpanel id="my-panel" label="Hello, World" />
</statusbar>

</overlay>


getUsers.js

var xmlhttp;
function getUsers(u)
{
alert('hi');
xmlhttp=new XMLHttpRequest();
var url="servercode.php?q="+u;

xmlhttp.onreadystatechange= useHttpResponse;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function useHttpResponse()
{
alert(xmlhttp.readyState);
if (xmlhttp.readyState==4 )
{
alert(xmlhttp.responseText);
}


}


verifyusernamepasswd():

var xml;
function verifyusernamepasswd()
{

var usernamebox=document.getElementById("some-text");
var passwordbox = document.getElementById("Userpassword");
var username=usernamebox.value;
var password=passwordbox.value;
alert(username);

xml=new XMLHttpRequest();
var url="loginvalidate.php";
var param="q="+username+"&p="+password;

xml.open("POST",url,true);
xml.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xml.setRequestHeader("Content-length", param.length);
xml.setRequestHeader("Connection", "close");


xml.onreadystatechange=statechanged1();

xml.send(param);

}

function statechanged1()
{
if(xml.readyState==4 && xml.status==200)

alert(xml.responseText);

}


servercode.php

<?php

$q=$_GET["q"];
$con=mysql_connect("localhost","root","blaze");
if(!$con)
{die('could not connect to database'.mysql.error());
}
mysql_select_db("BLAZE",$con) or die("No such Db");

$result=mysql_query("SELECT * FROM USERURL WHERE url='php.com'");
if($result == null)
echo 'halla';

header('Content-type: text/html');
echo '{Users:[';


while($row=mysql_fetch_array($result))
{
echo"{UserId:".$row[UsrID]."},";
}


echo "]}";

mysql_close($con);
?>

loginvalidate.php:

<?php

$con = mysql_connect("localhost","root","blaze");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$username=$_POST['username'];
$password=$_POST['password'];
var $false="false";
var $true="true";
mysql_select_db("BLAZE",$con);
$result=mysql_query("SELECT Userid,Password FROM USERTABLE WHERE Userid='$username'");
if($result==NULL)
echo $false;
else
{
$row=mysql_fetch_array($result)
if((strcmp($row["Userid"],$username)!=0)||(strcmp($row["Password"],$password)!=0))
{
echo $false;
}
else
echo $true;
}
?>


my problem is that i cant get the response of the php to the extension. there is proper connection between my javascript n php...for eg, i ran the javascript in html in /var/wwww here server code is n i got output. but wen i integrated it with the extension, i din get the response from php to the extension...

what could possibly be wrong????????
 
Old 03-18-2010, 03:41 AM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,287

Rep: Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034
I'd ask the mods to move this to the Programming forum if I were you...
 
Old 03-18-2010, 09:22 PM   #5
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
I've moved your thread to "Programming" so that it gets the exposure it deserves. It doesn't really fit into the "Linux Server" forum.

Kind regards,
Sasha
 
  


Reply

Tags
pls


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extension Server communication Neethusha Programming 1 03-18-2010 05:38 PM
firegpg firefox extension fakie_flip Linux - Software 0 12-29-2007 06:01 PM
Firefox extension pueblonative Linux - Software 2 02-07-2007 08:03 AM
looking for a firefox extension win32sux Linux - Software 2 05-31-2005 06:28 PM


All times are GMT -5. The time now is 03:21 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration