From 0a22c8fd4af6ffa2f205d23782c95a45f45823b5 Mon Sep 17 00:00:00 2001
From: Alexandre Lision <alexandre.lision@gmail.com>
Date: Sun, 29 Mar 2015 21:40:06 -0400
Subject: [PATCH] call: detect ring calls to prepend 'ring:'

Refs #67102

Change-Id: I7655cf5ffe3c63e459636bdd72e1ed9505627bdb
---
 RingWindowController.mm | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/RingWindowController.mm b/RingWindowController.mm
index f7a08c42..59eb8873 100644
--- a/RingWindowController.mm
+++ b/RingWindowController.mm
@@ -201,7 +201,17 @@ static NSString* const kCallButtonIdentifer = @"CallButtonIdentifier";
 - (IBAction)placeCall:(id)sender
 {
     Call* c = CallModel::instance()->dialingCall();
-    c->setDialNumber(QString::fromNSString([callField stringValue]));
+
+    // check for a valid ring hash
+    NSCharacterSet *hexSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789abcdefABCDEF"];
+    BOOL valid = [[[callField stringValue] stringByTrimmingCharactersInSet:hexSet] isEqualToString:@""];
+
+    if(valid && callField.stringValue.length == 40) {
+        c->setDialNumber(QString::fromNSString([NSString stringWithFormat:@"ring:%@",[callField stringValue]]));
+    } else {
+        c->setDialNumber(QString::fromNSString([callField stringValue]));
+    }
+
     c << Call::Action::ACCEPT;
 }
 
-- 
GitLab