Skip to content

Commit

Permalink
(Authentication) GUI for NickServ and SASL
Browse files Browse the repository at this point in the history
  • Loading branch information
pocmo committed Jun 10, 2011
1 parent 571090a commit 2fde755
Show file tree
Hide file tree
Showing 15 changed files with 564 additions and 77 deletions.
6 changes: 5 additions & 1 deletion application/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
<activity
android:name=".activity.UserActivity"
android:theme="@android:style/Theme.Dialog">
</activity>
</activity>
<activity
android:name=".activity.AuthenticationActivity"
android:theme="@android:style/Theme.Dialog">
</activity>
<service android:name=".irc.IRCService"></service>
</application>
<uses-sdk android:minSdkVersion="4" />
Expand Down
20 changes: 20 additions & 0 deletions application/res/layout/aliasadd.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Yaaic - Yet Another Android IRC Client
Copyright 2009-2011 Sebastian Kaspari
This file is part of Yaaic.
Yaaic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Yaaic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
Expand Down
20 changes: 20 additions & 0 deletions application/res/layout/aliasitem.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Yaaic - Yet Another Android IRC Client
Copyright 2009-2011 Sebastian Kaspari
This file is part of Yaaic.
Yaaic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Yaaic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/host"
android:layout_width="fill_parent"
Expand Down
95 changes: 95 additions & 0 deletions application/res/layout/authentication.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Yaaic - Yet Another Android IRC Client
Copyright 2009-2011 Sebastian Kaspari
This file is part of Yaaic.
Yaaic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Yaaic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Yaaic will authenticate you with these services after connect."
android:padding="5dp" />
<CheckBox
android:id="@+id/nickserv_checkbox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Authenticate with Nickserv" />
<TextView
android:id="@+id/nickserv_label_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Nickserv password"
android:enabled="false" />
<EditText
android:id="@+id/nickserv_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:password="true" />
<CheckBox
android:id="@+id/sasl_checkbox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Authenticate via SASL" />
<TextView
android:id="@+id/sasl_label_username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="SASL username"
android:enabled="false" />
<EditText
android:id="@+id/sasl_username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:enabled="false" />
<TextView
android:id="@+id/sasl_label_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="SASL password"
android:enabled="false"/>
<EditText
android:id="@+id/sasl_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:password="true" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ok"
android:text="@string/action_ok"
android:minWidth="90dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/cancel"
android:text="@string/action_cancel"
android:minWidth="90dp" />
</LinearLayout>
</LinearLayout>
5 changes: 5 additions & 0 deletions application/res/layout/serveradd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
android:gravity="center_horizontal"
android:padding="3dp"
android:layout_margin="2dp" />
<Button
android:id="@+id/authentication"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/authentication" />
<Button
android:id="@+id/channels"
android:layout_width="fill_parent"
Expand Down
1 change: 1 addition & 0 deletions application/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<string name="realname">Real Name</string>

<string name="server">Server</string>
<string name="authentication">Authentication</string>
<string name="channel">Channel</string>
<string name="channels">Channels</string>
<string name="commands">Commands</string>
Expand Down
53 changes: 29 additions & 24 deletions application/src/org/yaaic/activity/AddServerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.yaaic.Yaaic;
import org.yaaic.db.Database;
import org.yaaic.exception.ValidationException;
import org.yaaic.model.Authentication;
import org.yaaic.model.Extra;
import org.yaaic.model.Identity;
import org.yaaic.model.Server;
Expand All @@ -53,11 +54,13 @@
*/
public class AddServerActivity extends Activity implements OnClickListener
{
private static final int REQUEST_CODE_CHANNELS = 1;
private static final int REQUEST_CODE_COMMANDS = 2;
private static final int REQUEST_CODE_ALIASES = 3;
private static final int REQUEST_CODE_CHANNELS = 1;
private static final int REQUEST_CODE_COMMANDS = 2;
private static final int REQUEST_CODE_ALIASES = 3;
private static final int REQUEST_CODE_AUTHENTICATION = 4;

private Server server;
private Authentication authentication;
private ArrayList<String> aliases;
private ArrayList<String> channels;
private ArrayList<String> commands;
Expand All @@ -71,6 +74,8 @@ public void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);

setContentView(R.layout.serveradd);

authentication = new Authentication();
aliases = new ArrayList<String>();
channels = new ArrayList<String>();
commands = new ArrayList<String>();
Expand All @@ -80,6 +85,7 @@ public void onCreate(Bundle savedInstanceState)
((Button) findViewById(R.id.aliases)).setOnClickListener(this);
((Button) findViewById(R.id.channels)).setOnClickListener(this);
((Button) findViewById(R.id.commands)).setOnClickListener(this);
((Button) findViewById(R.id.authentication)).setOnClickListener(this);

Spinner spinner = (Spinner) findViewById(R.id.charset);
String[] charsets = getResources().getStringArray(R.array.charsets);
Expand All @@ -95,6 +101,7 @@ public void onCreate(Bundle savedInstanceState)
aliases.addAll(server.getIdentity().getAliases());
this.channels = db.getChannelsByServerId(server.getId());
this.commands = db.getCommandsByServerId(server.getId());
this.authentication = server.getAuthentication();
db.close();

// Set server values
Expand Down Expand Up @@ -153,6 +160,12 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data)
case REQUEST_CODE_COMMANDS:
commands = data.getExtras().getStringArrayList(Extra.COMMANDS);
break;

case REQUEST_CODE_AUTHENTICATION:
authentication.setSaslUsername(data.getExtras().getString(Extra.SASL_USER));
authentication.setSaslPassword(data.getExtras().getString(Extra.SASL_PASSWORD));
authentication.setNickservPassword(data.getExtras().getString(Extra.NICKSERV_PASSWORD));
break;
}
}

Expand All @@ -169,6 +182,14 @@ public void onClick(View v)
startActivityForResult(aliasIntent, REQUEST_CODE_ALIASES);
break;

case R.id.authentication:
Intent authIntent = new Intent(this, AuthenticationActivity.class);
authIntent.putExtra(Extra.NICKSERV_PASSWORD, authentication.getNickservPassword());
authIntent.putExtra(Extra.SASL_USER, authentication.getSaslUsername());
authIntent.putExtra(Extra.SASL_PASSWORD, authentication.getSaslPassword());
startActivityForResult(authIntent, REQUEST_CODE_AUTHENTICATION);
break;

case R.id.channels:
Intent channelIntent = new Intent(this, AddChannelActivity.class);
channelIntent.putExtra(Extra.CHANNELS, channels);
Expand Down Expand Up @@ -220,16 +241,9 @@ private void addServer()
);

Server server = getServerFromView();
long serverId = db.addServer(
server.getTitle(),
server.getHost(),
server.getPort(),
server.getPassword(),
false, // auto connect
server.useSSL(),
identityId,
server.getCharset()
);
server.setAuthentication(authentication);

long serverId = db.addServer(server, (int) identityId);

db.setChannels((int) serverId, channels);
db.setCommands((int) serverId, commands);
Expand All @@ -255,17 +269,8 @@ private void updateServer()
int identityId = db.getIdentityIdByServerId(serverId);

Server server = getServerFromView();
db.updateServer(
serverId,
server.getTitle(),
server.getHost(),
server.getPort(),
server.getPassword(),
false, // auto connect
server.useSSL(),
identityId,
server.getCharset()
);
server.setAuthentication(authentication);
db.updateServer(serverId, server, identityId);

Identity identity = getIdentityFromView();
db.updateIdentity(
Expand Down
Loading

0 comments on commit 2fde755

Please sign in to comment.